mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-26 04:05:53 +01:00
Pandora version build 07, with notaz improvements
This commit is contained in:
parent
dce391583c
commit
4108f92185
10
Sources/Engine/Base/Base.h
Normal file → Executable file
10
Sources/Engine/Base/Base.h
Normal file → Executable file
|
@ -77,4 +77,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define ENGINE_API
|
#define ENGINE_API
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
4
Sources/Engine/Base/Profiling.h
Normal file → Executable file
4
Sources/Engine/Base/Profiling.h
Normal file → Executable file
|
@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENGINE_INTERNAL
|
#if ENGINE_INTERNAL && !defined(PANDORA)
|
||||||
|
|
||||||
#include <Engine/Base/CTString.h>
|
#include <Engine/Base/CTString.h>
|
||||||
#include <Engine/Base/Timer.h>
|
#include <Engine/Base/Timer.h>
|
||||||
|
@ -68,7 +68,7 @@ private:
|
||||||
class CProfileForm {
|
class CProfileForm {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#if ENGINE_INTERNAL
|
#if ENGINE_INTERNAL && !defined(PANDORA)
|
||||||
// implementation:
|
// implementation:
|
||||||
CTString pf_strTitle; // main title of the profiling form
|
CTString pf_strTitle; // main title of the profiling form
|
||||||
CTString pf_strAveragingUnits; // name for averaging units
|
CTString pf_strAveragingUnits; // name for averaging units
|
||||||
|
|
|
@ -195,3 +195,8 @@ void STAT_Report(CTString &strReport)
|
||||||
{
|
{
|
||||||
_sfStats.Report(strReport);
|
_sfStats.Report(strReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STAT_Enable(BOOL enable)
|
||||||
|
{
|
||||||
|
_sfStats.sf_enabled = enable;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ ENGINE_API void STAT_Reset(void);
|
||||||
// make a new report
|
// make a new report
|
||||||
ENGINE_API void STAT_Report(CTString &strReport);
|
ENGINE_API void STAT_Report(CTString &strReport);
|
||||||
|
|
||||||
|
ENGINE_API void STAT_Enable(BOOL enable);
|
||||||
|
|
||||||
#endif /* include-once check. */
|
#endif /* include-once check. */
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
CStaticArray<class CStatCounter> sf_ascCounters; // profiling counters
|
CStaticArray<class CStatCounter> sf_ascCounters; // profiling counters
|
||||||
CStaticArray<class CStatTimer> sf_astTimers; // profiling timers
|
CStaticArray<class CStatTimer> sf_astTimers; // profiling timers
|
||||||
CStaticArray<class CStatLabel> sf_aslLabels; // profiling labels
|
CStaticArray<class CStatLabel> sf_aslLabels; // profiling labels
|
||||||
|
BOOL sf_enabled;
|
||||||
|
|
||||||
// interface:
|
// interface:
|
||||||
enum StatLabelIndex
|
enum StatLabelIndex
|
||||||
|
@ -157,12 +158,14 @@ public:
|
||||||
inline void StartTimer(INDEX iTimer) {
|
inline void StartTimer(INDEX iTimer) {
|
||||||
CStatTimer &st = sf_astTimers[iTimer];
|
CStatTimer &st = sf_astTimers[iTimer];
|
||||||
ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue == -1);
|
ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue == -1);
|
||||||
|
if (sf_enabled)
|
||||||
st.st_tvStarted = _pTimer->GetHighPrecisionTimer();
|
st.st_tvStarted = _pTimer->GetHighPrecisionTimer();
|
||||||
};
|
};
|
||||||
/* Stop a timer. */
|
/* Stop a timer. */
|
||||||
inline void StopTimer(INDEX iTimer) {
|
inline void StopTimer(INDEX iTimer) {
|
||||||
CStatTimer &st = sf_astTimers[iTimer];
|
CStatTimer &st = sf_astTimers[iTimer];
|
||||||
ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue != -1);
|
ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue != -1);
|
||||||
|
if (sf_enabled)
|
||||||
st.st_tvElapsed += _pTimer->GetHighPrecisionTimer()-st.st_tvStarted;
|
st.st_tvElapsed += _pTimer->GetHighPrecisionTimer()-st.st_tvStarted;
|
||||||
st.st_tvStarted.tv_llValue = -1;
|
st.st_tvStarted.tv_llValue = -1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,6 +180,8 @@ void CTimer_TimerFunc_internal(void)
|
||||||
_pTimer->tm_tvLastTimeOnTime = tvTimeNow;
|
_pTimer->tm_tvLastTimeOnTime = tvTimeNow;
|
||||||
_pTimer->tm_tmLastTickOnTime = tmTickNow;
|
_pTimer->tm_tmLastTickOnTime = tmTickNow;
|
||||||
|
|
||||||
|
_pTimer->tm_tvLowPrecisionTimer = tvTimeNow;
|
||||||
|
|
||||||
// } CTSTREAM_END;
|
// } CTSTREAM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ public:
|
||||||
CTimerValue tm_tvLastTimeOnTime; // last time when timer was on time
|
CTimerValue tm_tvLastTimeOnTime; // last time when timer was on time
|
||||||
TIME tm_tmLastTickOnTime; // last tick 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
|
TIME tm_RealTimeTimer; // this really ticks at 1/TickQuantum frequency
|
||||||
FLOAT tm_fLerpFactor; // factor used for lerping between frames
|
FLOAT tm_fLerpFactor; // factor used for lerping between frames
|
||||||
FLOAT tm_fLerpFactor2; // secondary lerp-factor used for unpredicted movement
|
FLOAT tm_fLerpFactor2; // secondary lerp-factor used for unpredicted movement
|
||||||
|
@ -137,6 +139,8 @@ public:
|
||||||
/* Get current timer value of high precision timer. */
|
/* Get current timer value of high precision timer. */
|
||||||
CTimerValue GetHighPrecisionTimer(void);
|
CTimerValue GetHighPrecisionTimer(void);
|
||||||
|
|
||||||
|
inline CTimerValue GetLowPrecisionTimer(void) const { return tm_tvLowPrecisionTimer; };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rcg10072001
|
* rcg10072001
|
||||||
* put current process to sleep for at least (milliseconds) milliseconds.
|
* put current process to sleep for at least (milliseconds) milliseconds.
|
||||||
|
|
|
@ -407,6 +407,8 @@ public:
|
||||||
/* Create a BSP polygon from this polygon. */
|
/* Create a BSP polygon from this polygon. */
|
||||||
void CreateBSPPolygon(BSPPolygon<DOUBLE, 3> &bspo);
|
void CreateBSPPolygon(BSPPolygon<DOUBLE, 3> &bspo);
|
||||||
void CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo);
|
void CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo);
|
||||||
|
void CreateBSPPolygon(BSPPolygon<FLOAT, 3> &bspo);
|
||||||
|
void CreateBSPPolygonNonPrecise(BSPPolygon<FLOAT, 3> &bspo);
|
||||||
/* Create shadow map for the polygon. */
|
/* Create shadow map for the polygon. */
|
||||||
void MakeShadowMap(CWorld *pwoWorld, BOOL bDoDirectionalLights);
|
void MakeShadowMap(CWorld *pwoWorld, BOOL bDoDirectionalLights);
|
||||||
/* Initialize shadow map for the polygon. */
|
/* Initialize shadow map for the polygon. */
|
||||||
|
@ -422,20 +424,21 @@ public:
|
||||||
void Triangulate(void);
|
void Triangulate(void);
|
||||||
public:
|
public:
|
||||||
// interface:
|
// interface:
|
||||||
|
FLOATaabbox3D bpo_boxBoundingBox; // bounding box
|
||||||
|
ULONG bpo_ulFlags; // flags
|
||||||
|
|
||||||
CBrushPlane *bpo_pbplPlane; // plane of this polygon
|
CBrushPlane *bpo_pbplPlane; // plane of this polygon
|
||||||
CStaticArray<CBrushPolygonEdge> bpo_abpePolygonEdges; // edges in this polygon
|
CStaticArray<CBrushPolygonEdge> bpo_abpePolygonEdges; // edges in this polygon
|
||||||
CStaticArray<CBrushVertex *> bpo_apbvxTriangleVertices; // triangle vertices
|
CStaticArray<CBrushVertex *> bpo_apbvxTriangleVertices; // triangle vertices
|
||||||
CStaticArray<INDEX> bpo_aiTriangleElements; // element indices inside vertex arrays
|
CStaticArray<INDEX> bpo_aiTriangleElements; // element indices inside vertex arrays
|
||||||
CBrushPolygonTexture bpo_abptTextures[3]; // texture on this polygon
|
CBrushPolygonTexture bpo_abptTextures[3]; // texture on this polygon
|
||||||
COLOR bpo_colColor; // color of this polygon
|
COLOR bpo_colColor; // color of this polygon
|
||||||
ULONG bpo_ulFlags; // flags
|
|
||||||
COLOR bpo_colShadow; // color of shadow on this polygon
|
COLOR bpo_colShadow; // color of shadow on this polygon
|
||||||
CBrushShadowMap bpo_smShadowMap; // shadow map of this polygon
|
CBrushShadowMap bpo_smShadowMap; // shadow map of this polygon
|
||||||
CMappingDefinition bpo_mdShadow; // mapping of shadow on polygon
|
CMappingDefinition bpo_mdShadow; // mapping of shadow on polygon
|
||||||
CBrushPolygonProperties bpo_bppProperties; // additional properties
|
CBrushPolygonProperties bpo_bppProperties; // additional properties
|
||||||
class CScreenPolygon *bpo_pspoScreenPolygon; // used in rendering
|
class CScreenPolygon *bpo_pspoScreenPolygon; // used in rendering
|
||||||
|
|
||||||
FLOATaabbox3D bpo_boxBoundingBox; // bounding box
|
|
||||||
CBrushSector *bpo_pbscSector; // sector of this polygon
|
CBrushSector *bpo_pbscSector; // sector of this polygon
|
||||||
|
|
||||||
CRelationSrc bpo_rsOtherSideSectors; // relation to sectors on other side of portal
|
CRelationSrc bpo_rsOtherSideSectors; // relation to sectors on other side of portal
|
||||||
|
@ -479,7 +482,7 @@ public:
|
||||||
|
|
||||||
// get amount of memory used by this object
|
// get amount of memory used by this object
|
||||||
SLONG GetUsedMemory(void);
|
SLONG GetUsedMemory(void);
|
||||||
};
|
} __attribute__((aligned(64)));
|
||||||
|
|
||||||
// get pointer to embedding brush polygon
|
// get pointer to embedding brush polygon
|
||||||
inline CBrushPolygon *CBrushShadowMap::GetBrushPolygon(void) {
|
inline CBrushPolygon *CBrushShadowMap::GetBrushPolygon(void) {
|
||||||
|
@ -562,7 +565,7 @@ public:
|
||||||
FLOATaabbox3D bsc_boxBoundingBox; // bounding box in absolute space
|
FLOATaabbox3D bsc_boxBoundingBox; // bounding box in absolute space
|
||||||
FLOATaabbox3D bsc_boxRelative; // bounding box in relative space
|
FLOATaabbox3D bsc_boxRelative; // bounding box in relative space
|
||||||
CListNode bsc_lnInActiveSectors; // node in sectors active in some operation (e.g. rendering)
|
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
|
CRelationDst bsc_rdOtherSidePortals; // relation to portals pointing to this sector
|
||||||
CRelationSrc bsc_rsEntities; // relation to all entities in this sector
|
CRelationSrc bsc_rsEntities; // relation to all entities in this sector
|
||||||
CTString bsc_strName; // sector name
|
CTString bsc_strName; // sector name
|
||||||
|
|
|
@ -150,10 +150,10 @@ void CBrushArchive::LinkPortalsAndSectors(void)
|
||||||
}
|
}
|
||||||
// create a BSP polygon from the brush polygon
|
// create a BSP polygon from the brush polygon
|
||||||
CBrushPolygon &brpo2 = *itbpo2;
|
CBrushPolygon &brpo2 = *itbpo2;
|
||||||
BSPPolygon<DOUBLE, 3> bspo2;
|
BSPPolygon<FLOAT, 3> bspo2;
|
||||||
brpo2.CreateBSPPolygonNonPrecise(bspo2);
|
brpo2.CreateBSPPolygonNonPrecise(bspo2);
|
||||||
// split the polygon with the BSP of the sector
|
// 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 anything remains on the border looking outside
|
||||||
if (bcCutter.bc_abedInside.Count()>0
|
if (bcCutter.bc_abedInside.Count()>0
|
||||||
||bcCutter.bc_abedBorderInside.Count()>0
|
||bcCutter.bc_abedBorderInside.Count()>0
|
||||||
|
|
|
@ -100,6 +100,34 @@ void CBrushPolygon::CreateBSPPolygon(BSPPolygon<DOUBLE, 3> &bspo)
|
||||||
}}
|
}}
|
||||||
bspo.bpo_abedPolygonEdges.Unlock();
|
bspo.bpo_abedPolygonEdges.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBrushPolygon::CreateBSPPolygon(BSPPolygon<FLOAT, 3> &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<ctEdges; iEdge++){
|
||||||
|
CBrushPolygonEdge &brped = brpo.bpo_abpePolygonEdges[iEdge];
|
||||||
|
BSPEdge<FLOAT, 3> &bed = bspo.bpo_abedPolygonEdges[iEdge];
|
||||||
|
// create the bsp edge in the bsp polygon
|
||||||
|
Vector<DOUBLE, 3> v0, v1;
|
||||||
|
brped.GetVertexCoordinatesPreciseAbsolute(v0, v1);
|
||||||
|
bed.bed_vVertex0 = DOUBLEtoFLOAT(v0);
|
||||||
|
bed.bed_vVertex1 = DOUBLEtoFLOAT(v1);
|
||||||
|
}}
|
||||||
|
bspo.bpo_abedPolygonEdges.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo)
|
void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo)
|
||||||
{
|
{
|
||||||
CBrushPolygon &brpo = *this;
|
CBrushPolygon &brpo = *this;
|
||||||
|
@ -133,6 +161,39 @@ void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo)
|
||||||
bspo.bpo_abedPolygonEdges.Unlock();
|
bspo.bpo_abedPolygonEdges.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon<FLOAT, 3> &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<ctEdges; iEdge++){
|
||||||
|
CBrushPolygonEdge &brped = brpo.bpo_abpePolygonEdges[iEdge];
|
||||||
|
BSPEdge<FLOAT, 3> &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.
|
* Select adjacent polygons with same color as this one.
|
||||||
*/
|
*/
|
||||||
|
|
12
Sources/Engine/Brushes/BrushSector.cpp
Normal file → Executable file
12
Sources/Engine/Brushes/BrushSector.cpp
Normal file → Executable file
|
@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
//template CDynamicArray<CBrushVertex>;
|
//template CDynamicArray<CBrushVertex>;
|
||||||
|
|
||||||
CBrushSector::CBrushSector(const CBrushSector &c)
|
CBrushSector::CBrushSector(const CBrushSector &c)
|
||||||
: bsc_bspBSPTree(*new DOUBLEbsptree3D)
|
: bsc_bspBSPTree(*new FLOATbsptree3D)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
};
|
};
|
||||||
|
@ -53,8 +53,8 @@ CBrushSector::CBrushSector(void)
|
||||||
, bsc_ulFlags2(0)
|
, bsc_ulFlags2(0)
|
||||||
, bsc_ulTempFlags(0)
|
, bsc_ulTempFlags(0)
|
||||||
, bsc_ulVisFlags(0)
|
, bsc_ulVisFlags(0)
|
||||||
, bsc_bspBSPTree(*new DOUBLEbsptree3D)
|
|
||||||
, bsc_strName("")
|
, 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) ) {
|
((pen->en_ulFlags&ENF_ZONING) || pen->en_RenderType==CEntity::RT_FIELDBRUSH) ) {
|
||||||
// create an array of bsp polygons for sector polygons
|
// create an array of bsp polygons for sector polygons
|
||||||
INDEX ctPolygons = bsc_abpoPolygons.Count();
|
INDEX ctPolygons = bsc_abpoPolygons.Count();
|
||||||
CDynamicArray< BSPPolygon<DOUBLE, 3> > arbpoPolygons;
|
CDynamicArray< BSPPolygon<FLOAT, 3> > arbpoPolygons;
|
||||||
arbpoPolygons.New(ctPolygons);
|
arbpoPolygons.New(ctPolygons);
|
||||||
|
|
||||||
// for all polygons in this sector
|
// for all polygons in this sector
|
||||||
|
@ -148,7 +148,7 @@ void CBrushSector::CalculateBoundingBoxes(CSimpleProjection3D_DOUBLE &prRelative
|
||||||
{for(INDEX iPolygon=0; iPolygon<ctPolygons; iPolygon++){
|
{for(INDEX iPolygon=0; iPolygon<ctPolygons; iPolygon++){
|
||||||
// create a BSP polygon from the brush polygon
|
// create a BSP polygon from the brush polygon
|
||||||
CBrushPolygon &brpo = bsc_abpoPolygons[iPolygon];
|
CBrushPolygon &brpo = bsc_abpoPolygons[iPolygon];
|
||||||
BSPPolygon<DOUBLE, 3> &bspo = arbpoPolygons[iPolygon];
|
BSPPolygon<FLOAT, 3> &bspo = arbpoPolygons[iPolygon];
|
||||||
brpo.CreateBSPPolygon(bspo);
|
brpo.CreateBSPPolygon(bspo);
|
||||||
}}
|
}}
|
||||||
arbpoPolygons.Unlock();
|
arbpoPolygons.Unlock();
|
||||||
|
@ -234,14 +234,14 @@ void CBrushSector::FindEntitiesInSector(void)
|
||||||
|
|
||||||
// if the sphere is inside the sector
|
// if the sphere is inside the sector
|
||||||
if (bsc_bspBSPTree.TestSphere(
|
if (bsc_bspBSPTree.TestSphere(
|
||||||
FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) {
|
vSphereCenter, fSphereRadius)>=0) {
|
||||||
// make oriented bounding box of the entity
|
// make oriented bounding box of the entity
|
||||||
FLOATobbox3D boxEntity(iten->en_boxSpatialClassification,
|
FLOATobbox3D boxEntity(iten->en_boxSpatialClassification,
|
||||||
iten->en_plPlacement.pl_PositionVector, iten->en_mRotation);
|
iten->en_plPlacement.pl_PositionVector, iten->en_mRotation);
|
||||||
|
|
||||||
// if the box is inside the sector
|
// if the box is inside the sector
|
||||||
if (boxSector.HasContactWith(boxEntity) &&
|
if (boxSector.HasContactWith(boxEntity) &&
|
||||||
bsc_bspBSPTree.TestBox(FLOATtoDOUBLE(boxEntity))>=0) {
|
bsc_bspBSPTree.TestBox(boxEntity)>=0) {
|
||||||
// relate the entity to the sector
|
// relate the entity to the sector
|
||||||
if (iten->en_RenderType==CEntity::RT_BRUSH
|
if (iten->en_RenderType==CEntity::RT_BRUSH
|
||||||
||iten->en_RenderType==CEntity::RT_FIELDBRUSH
|
||iten->en_RenderType==CEntity::RT_FIELDBRUSH
|
||||||
|
|
|
@ -899,8 +899,8 @@ functions:
|
||||||
}
|
}
|
||||||
|
|
||||||
// get min/max parameters of entity inside sector
|
// get min/max parameters of entity inside sector
|
||||||
double dMin, dMax;
|
float dMin, dMax;
|
||||||
bsc.bsc_bspBSPTree.FindLineMinMax(FLOATtoDOUBLE(vMin), FLOATtoDOUBLE(vMax), dMin, dMax);
|
bsc.bsc_bspBSPTree.FindLineMinMax(vMin, vMax, dMin, dMax);
|
||||||
|
|
||||||
// if sector content is not default
|
// if sector content is not default
|
||||||
INDEX iContent = bsc.GetContentType();
|
INDEX iContent = bsc.GetContentType();
|
||||||
|
|
12
Sources/Engine/Entities/Entity.cpp
Normal file → Executable file
12
Sources/Engine/Entities/Entity.cpp
Normal file → Executable file
|
@ -1826,7 +1826,6 @@ void CEntity::FindSectorsAroundEntity(void)
|
||||||
// make oriented bounding box of the entity
|
// make oriented bounding box of the entity
|
||||||
FLOATobbox3D boxEntity = FLOATobbox3D(en_boxSpatialClassification,
|
FLOATobbox3D boxEntity = FLOATobbox3D(en_boxSpatialClassification,
|
||||||
en_plPlacement.pl_PositionVector, en_mRotation);
|
en_plPlacement.pl_PositionVector, en_mRotation);
|
||||||
DOUBLEobbox3D boxdEntity = FLOATtoDOUBLE(boxEntity);
|
|
||||||
|
|
||||||
// unset spatial clasification
|
// unset spatial clasification
|
||||||
en_rdSectors.Clear();
|
en_rdSectors.Clear();
|
||||||
|
@ -1850,10 +1849,10 @@ void CEntity::FindSectorsAroundEntity(void)
|
||||||
|
|
||||||
// if the sphere is inside the sector
|
// if the sphere is inside the sector
|
||||||
if (itbsc->bsc_bspBSPTree.TestSphere(
|
if (itbsc->bsc_bspBSPTree.TestSphere(
|
||||||
FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) {
|
vSphereCenter, fSphereRadius)>=0) {
|
||||||
|
|
||||||
// if the box is inside the sector
|
// 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
|
// relate the entity to the sector
|
||||||
if (en_RenderType==RT_BRUSH
|
if (en_RenderType==RT_BRUSH
|
||||||
||en_RenderType==RT_FIELDBRUSH
|
||en_RenderType==RT_FIELDBRUSH
|
||||||
|
@ -1890,7 +1889,6 @@ void CEntity::FindSectorsAroundEntityNear(void)
|
||||||
// make oriented bounding box of the entity
|
// make oriented bounding box of the entity
|
||||||
FLOATobbox3D oboxEntity = FLOATobbox3D(en_boxSpatialClassification,
|
FLOATobbox3D oboxEntity = FLOATobbox3D(en_boxSpatialClassification,
|
||||||
en_plPlacement.pl_PositionVector, en_mRotation);
|
en_plPlacement.pl_PositionVector, en_mRotation);
|
||||||
DOUBLEobbox3D oboxdEntity = FLOATtoDOUBLE(oboxEntity);
|
|
||||||
|
|
||||||
CListHead lhActive;
|
CListHead lhActive;
|
||||||
// for each sector around this entity
|
// for each sector around this entity
|
||||||
|
@ -1921,13 +1919,13 @@ void CEntity::FindSectorsAroundEntityNear(void)
|
||||||
(pbsc->bsc_boxBoundingBox.HasContactWith(boxEntity))&&
|
(pbsc->bsc_boxBoundingBox.HasContactWith(boxEntity))&&
|
||||||
// the sphere is inside the sector
|
// the sphere is inside the sector
|
||||||
(pbsc->bsc_bspBSPTree.TestSphere(
|
(pbsc->bsc_bspBSPTree.TestSphere(
|
||||||
FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0)&&
|
vSphereCenter, fSphereRadius)>=0)&&
|
||||||
// (use more detailed testing for moving brushes)
|
// (use more detailed testing for moving brushes)
|
||||||
(en_RenderType!=RT_BRUSH||
|
(en_RenderType!=RT_BRUSH||
|
||||||
// oriented box touches box of sector
|
// oriented box touches box of sector
|
||||||
((oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&&
|
((oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&&
|
||||||
// oriented box is in bsp
|
// oriented box is in bsp
|
||||||
(pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0)));
|
(pbsc->bsc_bspBSPTree.TestBox(oboxEntity)>=0)));
|
||||||
// if it is not
|
// if it is not
|
||||||
if (!bIn) {
|
if (!bIn) {
|
||||||
// if it has link
|
// if it has link
|
||||||
|
@ -2866,7 +2864,7 @@ CBrushSector *CEntity::GetSectorFromPoint(const FLOAT3D &vPointAbs)
|
||||||
// for each sector around entity
|
// for each sector around entity
|
||||||
{FOREACHSRCOFDST(en_rdSectors, CBrushSector, bsc_rsEntities, pbsc)
|
{FOREACHSRCOFDST(en_rdSectors, CBrushSector, bsc_rsEntities, pbsc)
|
||||||
// if point is in this sector
|
// 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 that
|
||||||
return pbsc;
|
return pbsc;
|
||||||
}
|
}
|
||||||
|
|
0
Sources/Engine/Entities/Entity.h
Normal file → Executable file
0
Sources/Engine/Entities/Entity.h
Normal file → Executable file
|
@ -43,11 +43,10 @@ static BOOL EntityIsInside(CEntity *pen)
|
||||||
const FLOAT3D &v = pen->en_plPlacement.pl_PositionVector;
|
const FLOAT3D &v = pen->en_plPlacement.pl_PositionVector;
|
||||||
const FLOATmatrix3D &m = pen->en_mRotation;
|
const FLOATmatrix3D &m = pen->en_mRotation;
|
||||||
FLOATobbox3D boxEntity = FLOATobbox3D(pen->en_boxSpatialClassification, v, m);
|
FLOATobbox3D boxEntity = FLOATobbox3D(pen->en_boxSpatialClassification, v, m);
|
||||||
DOUBLEobbox3D boxdEntity = FLOATtoDOUBLE(boxEntity);
|
|
||||||
|
|
||||||
// if the box touches the sector's BSP
|
// if the box touches the sector's BSP
|
||||||
if (boxEntity.HasContactWith(FLOATobbox3D(_pbsc->bsc_boxBoundingBox)) &&
|
if (boxEntity.HasContactWith(FLOATobbox3D(_pbsc->bsc_boxBoundingBox)) &&
|
||||||
_pbsc->bsc_bspBSPTree.TestBox(boxdEntity)<=0) {
|
_pbsc->bsc_bspBSPTree.TestBox(boxEntity)<=0) {
|
||||||
|
|
||||||
// for each collision sphere
|
// for each collision sphere
|
||||||
CStaticArray<CMovingSphere> &absSpheres = pen->en_pciCollisionInfo->ci_absSpheres;
|
CStaticArray<CMovingSphere> &absSpheres = pen->en_pciCollisionInfo->ci_absSpheres;
|
||||||
|
@ -56,7 +55,7 @@ static BOOL EntityIsInside(CEntity *pen)
|
||||||
ms.ms_vRelativeCenter0 = ms.ms_vCenter*m+v;
|
ms.ms_vRelativeCenter0 = ms.ms_vCenter*m+v;
|
||||||
// if the sphere is in the sector
|
// if the sphere is in the sector
|
||||||
if (_pbsc->bsc_bspBSPTree.TestSphere(
|
if (_pbsc->bsc_bspBSPTree.TestSphere(
|
||||||
FLOATtoDOUBLE(ms.ms_vRelativeCenter0), ms.ms_fR)<=0) {
|
ms.ms_vRelativeCenter0, ms.ms_fR)<=0) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
Sources/Engine/Graphics/Benchmark.cpp
Normal file → Executable file
4
Sources/Engine/Graphics/Benchmark.cpp
Normal file → Executable file
|
@ -48,7 +48,7 @@ static CTexParams _tpLocal;
|
||||||
static CStaticStackArray<GFXVertex> _avtx;
|
static CStaticStackArray<GFXVertex> _avtx;
|
||||||
static CStaticStackArray<GFXTexCoord> _atex;
|
static CStaticStackArray<GFXTexCoord> _atex;
|
||||||
static CStaticStackArray<GFXColor> _acol;
|
static CStaticStackArray<GFXColor> _acol;
|
||||||
static CStaticStackArray<INDEX> _aiElements;
|
static CStaticStackArray<INDEX_T> _aiElements;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ static DOUBLE FillRatePass(INDEX ct)
|
||||||
avtx[3].x = _pixSizeI; avtx[3].y = 0; avtx[3].z = 0.5f;
|
avtx[3].x = _pixSizeI; avtx[3].y = 0; avtx[3].z = 0.5f;
|
||||||
GFXTexCoord atex[4] = { {0,0}, {0,1}, {1,1}, {1,0} };
|
GFXTexCoord atex[4] = { {0,0}, {0,1}, {1,1}, {1,0} };
|
||||||
GFXColor acol[4] = { 0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFF00FF };
|
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);
|
gfxSetVertexArray( &avtx[0], 4);
|
||||||
gfxSetTexCoordArray( &atex[0], FALSE);
|
gfxSetTexCoordArray( &atex[0], FALSE);
|
||||||
gfxSetColorArray( &acol[0]);
|
gfxSetColorArray( &acol[0]);
|
||||||
|
|
2
Sources/Engine/Graphics/DepthCheck.cpp
Normal file → Executable file
2
Sources/Engine/Graphics/DepthCheck.cpp
Normal file → Executable file
|
@ -251,7 +251,7 @@ extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel/*=
|
||||||
ASSERT( pdp!=NULL && iMirrorLevel>=0);
|
ASSERT( pdp!=NULL && iMirrorLevel>=0);
|
||||||
|
|
||||||
// check only if time lapse allows
|
// check only if time lapse allows
|
||||||
const CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
|
const CTimerValue tvNow = _pTimer->GetLowPrecisionTimer();
|
||||||
const TIME tmDelta = (tvNow-_tvLast[iMirrorLevel]).GetSeconds();
|
const TIME tmDelta = (tvNow-_tvLast[iMirrorLevel]).GetSeconds();
|
||||||
ASSERT( tmDelta>=0);
|
ASSERT( tmDelta>=0);
|
||||||
if( gap_iOptimizeDepthReads==2 && tmDelta<0.1f) return;
|
if( gap_iOptimizeDepthReads==2 && tmDelta<0.1f) return;
|
||||||
|
|
|
@ -1567,7 +1567,7 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fI1, c
|
||||||
GFXVertex *pvtx = _avtxCommon.Push(4);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
GFXTexCoord *ptex = _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.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[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
||||||
pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].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;
|
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);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
GFXTexCoord *ptex = _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.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[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
||||||
pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].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;
|
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);
|
GFXVertex *pvtx = _avtxCommon.Push(3);
|
||||||
/* GFXTexCoord *ptex = */ _atexCommon.Push(3);
|
/* GFXTexCoord *ptex = */ _atexCommon.Push(3);
|
||||||
GFXColor *pcol = _acolCommon.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[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
||||||
pvtx[1].x = fI1; pvtx[1].y = fJ1; pvtx[1].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;
|
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);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
GFXTexCoord *ptex = _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.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[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
||||||
pvtx[1].x = fI1; pvtx[1].y = fJ1; pvtx[1].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;
|
pvtx[2].x = fI2; pvtx[2].y = fJ2; pvtx[2].z = 0;
|
||||||
|
|
4
Sources/Engine/Graphics/DrawPort_RenderScene.cpp
Normal file → Executable file
4
Sources/Engine/Graphics/DrawPort_RenderScene.cpp
Normal file → Executable file
|
@ -62,7 +62,7 @@ static GfxAPIType eAPI;
|
||||||
static CStaticStackArray<GFXVertex> _avtxPass;
|
static CStaticStackArray<GFXVertex> _avtxPass;
|
||||||
static CStaticStackArray<GFXTexCoord> _atexPass[MAXTEXUNITS];
|
static CStaticStackArray<GFXTexCoord> _atexPass[MAXTEXUNITS];
|
||||||
static CStaticStackArray<GFXColor> _acolPass;
|
static CStaticStackArray<GFXColor> _acolPass;
|
||||||
static CStaticStackArray<INDEX> _aiElements;
|
static CStaticStackArray<INDEX_T> _aiElements;
|
||||||
// general coordinate stack referenced by the scene polygons
|
// general coordinate stack referenced by the scene polygons
|
||||||
CStaticStackArray<GFXVertex3> _avtxScene;
|
CStaticStackArray<GFXVertex3> _avtxScene;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ __forceinline
|
||||||
void AddElements( ScenePolygon *pspo)
|
void AddElements( ScenePolygon *pspo)
|
||||||
{
|
{
|
||||||
const INDEX ctElems = pspo->spo_ctElements;
|
const INDEX ctElems = pspo->spo_ctElements;
|
||||||
INDEX *piDst = _aiElements.Push(ctElems);
|
INDEX_T *piDst = _aiElements.Push(ctElems);
|
||||||
|
|
||||||
#if (defined __MSVC_INLINE__)
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
|
|
8
Sources/Engine/Graphics/GfxLibrary.cpp
Normal file → Executable file
8
Sources/Engine/Graphics/GfxLibrary.cpp
Normal file → Executable file
|
@ -66,8 +66,8 @@ BOOL CVA_bModels = FALSE;
|
||||||
CStaticStackArray<GFXVertex> _avtxCommon;
|
CStaticStackArray<GFXVertex> _avtxCommon;
|
||||||
CStaticStackArray<GFXTexCoord> _atexCommon;
|
CStaticStackArray<GFXTexCoord> _atexCommon;
|
||||||
CStaticStackArray<GFXColor> _acolCommon;
|
CStaticStackArray<GFXColor> _acolCommon;
|
||||||
CStaticStackArray<INDEX> _aiCommonElements;
|
CStaticStackArray<INDEX_T> _aiCommonElements;
|
||||||
CStaticStackArray<INDEX> _aiCommonQuads; // predefined array for rendering quads thru triangles in glDrawElements()
|
CStaticStackArray<INDEX_T> _aiCommonQuads; // predefined array for rendering quads thru triangles in glDrawElements()
|
||||||
|
|
||||||
// global texture parameters
|
// global texture parameters
|
||||||
CTexParams _tpGlobal[GFX_MAXTEXUNITS];
|
CTexParams _tpGlobal[GFX_MAXTEXUNITS];
|
||||||
|
@ -795,7 +795,7 @@ extern BOOL ProbeMode( CTimerValue tvLast)
|
||||||
}
|
}
|
||||||
// clamp and determine probe mode
|
// clamp and determine probe mode
|
||||||
if( gfx_tmProbeDecay>999) gfx_tmProbeDecay = 999;
|
if( gfx_tmProbeDecay>999) gfx_tmProbeDecay = 999;
|
||||||
CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
|
CTimerValue tvNow = _pTimer->GetLowPrecisionTimer();
|
||||||
const TIME tmDelta = (tvNow-tvLast).GetSeconds();
|
const TIME tmDelta = (tvNow-tvLast).GetSeconds();
|
||||||
if( tmDelta>gfx_tmProbeDecay) return TRUE;
|
if( tmDelta>gfx_tmProbeDecay) return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1718,7 +1718,7 @@ void CGfxLibrary::ReduceShadows(void)
|
||||||
// clamp shadow caching variables
|
// clamp shadow caching variables
|
||||||
shd_fCacheSize = Clamp( shd_fCacheSize, 0.1f, 128.0f);
|
shd_fCacheSize = Clamp( shd_fCacheSize, 0.1f, 128.0f);
|
||||||
shd_tmFlushDelay = Clamp( shd_tmFlushDelay, 0.1f, 120.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);
|
const TIME tmAcientDelay = Clamp( shd_tmFlushDelay*3, 60.0f, 300.0f);
|
||||||
|
|
||||||
// determine cached shadowmaps stats (if needed)
|
// determine cached shadowmaps stats (if needed)
|
||||||
|
|
4
Sources/Engine/Graphics/GfxLibrary.h
Normal file → Executable file
4
Sources/Engine/Graphics/GfxLibrary.h
Normal file → Executable file
|
@ -33,8 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
extern CStaticStackArray<GFXVertex> _avtxCommon;
|
extern CStaticStackArray<GFXVertex> _avtxCommon;
|
||||||
extern CStaticStackArray<GFXTexCoord> _atexCommon;
|
extern CStaticStackArray<GFXTexCoord> _atexCommon;
|
||||||
extern CStaticStackArray<GFXColor> _acolCommon;
|
extern CStaticStackArray<GFXColor> _acolCommon;
|
||||||
extern CStaticStackArray<INDEX> _aiCommonElements;
|
extern CStaticStackArray<INDEX_T> _aiCommonElements;
|
||||||
extern CStaticStackArray<INDEX> _aiCommonQuads;
|
extern CStaticStackArray<INDEX_T> _aiCommonQuads;
|
||||||
|
|
||||||
#include <Engine/Graphics/OpenGL.h>
|
#include <Engine/Graphics/OpenGL.h>
|
||||||
#include <Engine/Graphics/Gfx_wrapper.h>
|
#include <Engine/Graphics/Gfx_wrapper.h>
|
||||||
|
|
8
Sources/Engine/Graphics/Gfx_wrapper.cpp
Normal file → Executable file
8
Sources/Engine/Graphics/Gfx_wrapper.cpp
Normal file → Executable file
|
@ -126,7 +126,7 @@ void (*gfxSetVertexArray)( GFXVertex4 *pvtx, INDEX ctVtx) = NULL;
|
||||||
void (*gfxSetNormalArray)( GFXNormal *pnor) = NULL;
|
void (*gfxSetNormalArray)( GFXNormal *pnor) = NULL;
|
||||||
void (*gfxSetTexCoordArray)( GFXTexCoord *ptex, BOOL b4) = NULL;
|
void (*gfxSetTexCoordArray)( GFXTexCoord *ptex, BOOL b4) = NULL;
|
||||||
void (*gfxSetColorArray)( GFXColor *pcol) = 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 (*gfxSetConstantColor)(COLOR col) = NULL;
|
||||||
void (*gfxEnableColorArray)(void) = NULL;
|
void (*gfxEnableColorArray)(void) = NULL;
|
||||||
void (*gfxDisableColorArray)(void) = NULL;
|
void (*gfxDisableColorArray)(void) = NULL;
|
||||||
|
@ -555,7 +555,7 @@ extern void gfxUnlockArrays(void)
|
||||||
void AddQuadElements( const INDEX ctQuads)
|
void AddQuadElements( const INDEX ctQuads)
|
||||||
{
|
{
|
||||||
const INDEX iStart = _aiCommonQuads.Count() /6*4;
|
const INDEX iStart = _aiCommonQuads.Count() /6*4;
|
||||||
INDEX *piQuads = _aiCommonQuads.Push(ctQuads*6);
|
INDEX_T *piQuads = _aiCommonQuads.Push(ctQuads*6);
|
||||||
for( INDEX i=0; i<ctQuads; i++) {
|
for( INDEX i=0; i<ctQuads; i++) {
|
||||||
piQuads[i*6 +0] = iStart+ i*4 +0;
|
piQuads[i*6 +0] = iStart+ i*4 +0;
|
||||||
piQuads[i*6 +1] = iStart+ i*4 +1;
|
piQuads[i*6 +1] = iStart+ i*4 +1;
|
||||||
|
@ -568,7 +568,7 @@ void AddQuadElements( const INDEX ctQuads)
|
||||||
|
|
||||||
|
|
||||||
// helper function for flushers
|
// helper function for flushers
|
||||||
static void FlushArrays( INDEX *piElements, INDEX ctElements)
|
static void FlushArrays( INDEX_T *piElements, INDEX ctElements)
|
||||||
{
|
{
|
||||||
// check
|
// check
|
||||||
const INDEX ctVertices = _avtxCommon.Count();
|
const INDEX ctVertices = _avtxCommon.Count();
|
||||||
|
@ -686,7 +686,7 @@ static void none_SetVertexArray( GFXVertex4 *pvtx, INDEX ctVtx) { NOTHING; };
|
||||||
static void none_SetNormalArray( GFXNormal *pnor) { NOTHING; };
|
static void none_SetNormalArray( GFXNormal *pnor) { NOTHING; };
|
||||||
static void none_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4) { NOTHING; };
|
static void none_SetTexCoordArray( GFXTexCoord *ptex, BOOL b4) { NOTHING; };
|
||||||
static void none_SetColorArray( GFXColor *pcol) { NOTHING; };
|
static void none_SetColorArray( GFXColor *pcol) { NOTHING; };
|
||||||
static void none_DrawElements( INDEX ctElem, INDEX *pidx) { NOTHING; };
|
static void none_DrawElements( INDEX ctElem, INDEX_T *pidx) { NOTHING; };
|
||||||
static void none_SetConstantColor( COLOR col) { NOTHING; };
|
static void none_SetConstantColor( COLOR col) { NOTHING; };
|
||||||
static void none_SetColorMask( ULONG ulColorMask) { NOTHING; };
|
static void none_SetColorMask( ULONG ulColorMask) { NOTHING; };
|
||||||
|
|
||||||
|
|
2
Sources/Engine/Graphics/Gfx_wrapper.h
Normal file → Executable file
2
Sources/Engine/Graphics/Gfx_wrapper.h
Normal file → Executable file
|
@ -237,7 +237,7 @@ extern void (*gfxSetColorArray)( GFXColor *pcol);
|
||||||
|
|
||||||
|
|
||||||
// draw prepared arrays
|
// draw prepared arrays
|
||||||
extern void (*gfxDrawElements)( INDEX ctElem, INDEX *pidx);
|
extern void (*gfxDrawElements)( INDEX ctElem, INDEX_T *pidx);
|
||||||
|
|
||||||
// set constant color for subsequent rendering (until 1st gfxSetColorArray() call!)
|
// set constant color for subsequent rendering (until 1st gfxSetColorArray() call!)
|
||||||
extern void (*gfxSetConstantColor)(COLOR col);
|
extern void (*gfxSetConstantColor)(COLOR col);
|
||||||
|
|
4
Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp
Normal file → Executable file
4
Sources/Engine/Graphics/Gfx_wrapper_OpenGL.cpp
Normal file → Executable file
|
@ -1123,7 +1123,7 @@ static void ogl_SetConstantColor( COLOR col)
|
||||||
|
|
||||||
|
|
||||||
// draw prepared arrays
|
// draw prepared arrays
|
||||||
static void ogl_DrawElements( INDEX ctElem, INDEX *pidx)
|
static void ogl_DrawElements( INDEX ctElem, INDEX_T *pidx)
|
||||||
{
|
{
|
||||||
ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL);
|
ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -1136,7 +1136,7 @@ static void ogl_DrawElements( INDEX ctElem, INDEX *pidx)
|
||||||
|
|
||||||
// arrays or elements
|
// arrays or elements
|
||||||
if( pidx==NULL) pglDrawArrays( GL_QUADS, 0, ctElem);
|
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;
|
OGL_CHECKERROR;
|
||||||
|
|
||||||
_sfStats.StopTimer(CStatForm::STI_GFXAPI);
|
_sfStats.StopTimer(CStatForm::STI_GFXAPI);
|
||||||
|
|
6
Sources/Engine/Graphics/Shader.cpp
Normal file → Executable file
6
Sources/Engine/Graphics/Shader.cpp
Normal file → Executable file
|
@ -45,7 +45,7 @@ static GFXTexCoord *_paHazeUVMap = NULL; // UVMap for haze pass
|
||||||
static GFXColor *_pacolVtxHaze = NULL; // array of vertex colors for haze
|
static GFXColor *_pacolVtxHaze = NULL; // array of vertex colors for haze
|
||||||
|
|
||||||
static CTextureObject **_paTextures = NULL;// array of textures to chose from
|
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 GFXColor _colAmbient = 0x000000FF; // Ambient color
|
||||||
static COLOR _colModel = 0x000000FF; // Model color
|
static COLOR _colModel = 0x000000FF; // Model color
|
||||||
|
@ -352,7 +352,7 @@ void shaSetNormalArray(GFXNormal *paNormals)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set array of indices
|
// Set array of indices
|
||||||
void shaSetIndices(INDEX *paIndices,INDEX ctIndices)
|
void shaSetIndices(INDEX_T *paIndices,INDEX ctIndices)
|
||||||
{
|
{
|
||||||
ASSERT(paIndices!=NULL);
|
ASSERT(paIndices!=NULL);
|
||||||
ASSERT(ctIndices>0);
|
ASSERT(ctIndices>0);
|
||||||
|
@ -576,7 +576,7 @@ GFXVertex4 *shaGetVertexArray(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get index array
|
// Get index array
|
||||||
INDEX *shaGetIndexArray(void)
|
INDEX_T *shaGetIndexArray(void)
|
||||||
{
|
{
|
||||||
return _paIndices;
|
return _paIndices;
|
||||||
}
|
}
|
||||||
|
|
4
Sources/Engine/Graphics/Shader.h
Normal file → Executable file
4
Sources/Engine/Graphics/Shader.h
Normal file → Executable file
|
@ -97,7 +97,7 @@ ENGINE_API void shaSetVertexArray(GFXVertex4 *paVertices,INDEX ctVertices);
|
||||||
// Set array of normals
|
// Set array of normals
|
||||||
ENGINE_API void shaSetNormalArray(GFXNormal *paNormals);
|
ENGINE_API void shaSetNormalArray(GFXNormal *paNormals);
|
||||||
// Set array of indices
|
// 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
|
// Set array of texture objects for shader
|
||||||
ENGINE_API void shaSetTextureArray(CTextureObject **paTextureObject, INDEX ctTextures);
|
ENGINE_API void shaSetTextureArray(CTextureObject **paTextureObject, INDEX ctTextures);
|
||||||
// Set array of uv maps
|
// Set array of uv maps
|
||||||
|
@ -159,7 +159,7 @@ ENGINE_API COLOR &shaGetCurrentColor(void);
|
||||||
// Get vertex array
|
// Get vertex array
|
||||||
ENGINE_API GFXVertex4 *shaGetVertexArray(void);
|
ENGINE_API GFXVertex4 *shaGetVertexArray(void);
|
||||||
// Get index array
|
// Get index array
|
||||||
ENGINE_API INDEX *shaGetIndexArray(void);
|
ENGINE_API INDEX_T *shaGetIndexArray(void);
|
||||||
// Get normal array
|
// Get normal array
|
||||||
ENGINE_API GFXNormal *shaGetNormalArray(void);
|
ENGINE_API GFXNormal *shaGetNormalArray(void);
|
||||||
// Get uvmap array from array of uvmaps
|
// Get uvmap array from array of uvmaps
|
||||||
|
|
2
Sources/Engine/Graphics/ShadowMap.cpp
Normal file → Executable file
2
Sources/Engine/Graphics/ShadowMap.cpp
Normal file → Executable file
|
@ -251,7 +251,7 @@ void CShadowMap::MarkDrawn(void)
|
||||||
ASSERT( sm_lnInGfx.IsLinked());
|
ASSERT( sm_lnInGfx.IsLinked());
|
||||||
sm_lnInGfx.Remove();
|
sm_lnInGfx.Remove();
|
||||||
// set time stamp
|
// set time stamp
|
||||||
sm_tvLastDrawn = _pTimer->GetHighPrecisionTimer();
|
sm_tvLastDrawn = _pTimer->GetLowPrecisionTimer();
|
||||||
// put at the end of the list
|
// put at the end of the list
|
||||||
_pGfx->gl_lhCachedShadows.AddTail(sm_lnInGfx);
|
_pGfx->gl_lhCachedShadows.AddTail(sm_lnInGfx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
inline ULONG GetNoOfFineMips(void) const { return td_ctFineMipLevels; };
|
inline ULONG GetNoOfFineMips(void) const { return td_ctFineMipLevels; };
|
||||||
|
|
||||||
// mark that texture has been used
|
// 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
|
// get string description of texture size, mips and parameters
|
||||||
CTString GetDescription(void);
|
CTString GetDescription(void);
|
||||||
|
|
|
@ -417,7 +417,7 @@ void CLightSource::FindShadowLayersPoint(BOOL bSelectedOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
// for each layer of the light source
|
// for each layer of the light source
|
||||||
DOUBLE3D dvOrigin = FLOATtoDOUBLE(*_pvOrigin);
|
FLOAT3D dvOrigin = *_pvOrigin;
|
||||||
{FORDELETELIST(CBrushShadowLayer, bsl_lnInLightSource, ls_lhLayers, itbsl) {
|
{FORDELETELIST(CBrushShadowLayer, bsl_lnInLightSource, ls_lhLayers, itbsl) {
|
||||||
CBrushPolygon *pbpo = itbsl->bsl_pbsmShadowMap->GetBrushPolygon();
|
CBrushPolygon *pbpo = itbsl->bsl_pbsmShadowMap->GetBrushPolygon();
|
||||||
CEntity *penWithPolygon = pbpo->bpo_pbscSector->bsc_pbmBrushMip->bm_pbrBrush->br_penEntity;
|
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)
|
if (!itbsc->bsc_boxBoundingBox.HasContactWith(_boxLight)
|
||||||
||(itbsc->bsc_bspBSPTree.bt_pbnRoot!=NULL
|
||(itbsc->bsc_bspBSPTree.bt_pbnRoot!=NULL
|
||||||
&&!(itbsc->bsc_bspBSPTree.TestSphere(
|
&&!(itbsc->bsc_bspBSPTree.TestSphere(
|
||||||
dvOrigin, FLOATtoDOUBLE(_rRange))>=0) )) {
|
dvOrigin, _rRange)>=0) )) {
|
||||||
// skip it
|
// skip it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
47
Sources/Engine/Math/AABBox.h
Normal file → Executable file
47
Sources/Engine/Math/AABBox.h
Normal file → Executable file
|
@ -400,6 +400,53 @@ inline FLOATaabbox3D DOUBLEtoFLOAT(const DOUBLEaabbox3D &pld) {
|
||||||
return FLOATaabbox3D( DOUBLEtoFLOAT(pld.Min()), DOUBLEtoFLOAT(pld.Max()));
|
return FLOATaabbox3D( DOUBLEtoFLOAT(pld.Min()), DOUBLEtoFLOAT(pld.Max()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Specialized copy for FLOATaabb3D */
|
||||||
|
|
||||||
|
/* Check if intersects or touches another bounding box. */
|
||||||
|
template<>
|
||||||
|
inline BOOL AABBox<FLOAT, 3>::HasContactWith(const AABBox<FLOAT, 3> &b) const
|
||||||
|
{
|
||||||
|
// if spans in any dimension don't have contact
|
||||||
|
if (maxvect(1)<b.minvect(1) || minvect(1)>b.maxvect(1)
|
||||||
|
|| maxvect(2)<b.minvect(2) || minvect(2)>b.maxvect(2)
|
||||||
|
|| maxvect(3)<b.minvect(3) || minvect(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<FLOAT, 3>::HasContactWith(const AABBox<FLOAT, 3> &b, FLOAT tEpsilon) const
|
||||||
|
{
|
||||||
|
// if spans in any dimension don't have contact
|
||||||
|
if( (maxvect(1)+tEpsilon<b.minvect(1)) ||(minvect(1)-tEpsilon>b.maxvect(1))
|
||||||
|
|| (maxvect(2)+tEpsilon<b.minvect(2)) ||(minvect(2)-tEpsilon>b.maxvect(2))
|
||||||
|
|| (maxvect(3)+tEpsilon<b.minvect(3)) ||(minvect(3)-tEpsilon>b.maxvect(3))
|
||||||
|
) {
|
||||||
|
// whole bounding boxes don't have contact
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/* Check if intersects or touches a sphere. */
|
||||||
|
template<>
|
||||||
|
inline BOOL AABBox<FLOAT, 3>::TouchesSphere(
|
||||||
|
const Vector<FLOAT, 3> &vSphereCenter, FLOAT fSphereRadius) const
|
||||||
|
{
|
||||||
|
// if spans in any dimension don't have contact
|
||||||
|
if( (vSphereCenter(1)+fSphereRadius<minvect(1)) ||(vSphereCenter(1)-fSphereRadius>maxvect(1))
|
||||||
|
|| (vSphereCenter(2)+fSphereRadius<minvect(2)) ||(vSphereCenter(2)-fSphereRadius>maxvect(2))
|
||||||
|
|| (vSphereCenter(3)+fSphereRadius<minvect(3)) ||(vSphereCenter(3)-fSphereRadius>maxvect(3))
|
||||||
|
) {
|
||||||
|
// no contact
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* include-once check. */
|
#endif /* include-once check. */
|
||||||
|
|
||||||
|
|
0
Sources/Engine/Math/Clipping.inl
Normal file → Executable file
0
Sources/Engine/Math/Clipping.inl
Normal file → Executable file
0
Sources/Engine/Math/Matrix.h
Normal file → Executable file
0
Sources/Engine/Math/Matrix.h
Normal file → Executable file
2
Sources/Engine/Models/ModelData.h
Normal file → Executable file
2
Sources/Engine/Models/ModelData.h
Normal file → Executable file
|
@ -67,7 +67,7 @@ struct ENGINE_API ModelMipInfo
|
||||||
CStaticArray<FLOAT3D> mmpi_avBumpV; // bump directions for each surface vertex
|
CStaticArray<FLOAT3D> mmpi_avBumpV; // bump directions for each surface vertex
|
||||||
ULONG mmpi_ulLayerFlags; // all texture layers needed in this mip
|
ULONG mmpi_ulLayerFlags; // all texture layers needed in this mip
|
||||||
INDEX mmpi_ctTriangles; // total triangles in this mip
|
INDEX mmpi_ctTriangles; // total triangles in this mip
|
||||||
CStaticStackArray<INDEX> mmpi_aiElements;
|
CStaticStackArray<INDEX_T> mmpi_aiElements;
|
||||||
|
|
||||||
void Clear(); // clears this mip model's arays and their sub-arrays, dealocates memory
|
void Clear(); // clears this mip model's arays and their sub-arrays, dealocates memory
|
||||||
void Read_t( CTStream *istrFile, BOOL bReadPolygonalPatches, BOOL bReadPolygonsPerSurface,
|
void Read_t( CTStream *istrFile, BOOL bReadPolygonalPatches, BOOL bReadPolygonsPerSurface,
|
||||||
|
|
43
Sources/Engine/Models/RenderModel_View.cpp
Normal file → Executable file
43
Sources/Engine/Models/RenderModel_View.cpp
Normal file → Executable file
|
@ -332,7 +332,7 @@ static void PrepareSurfaceElements( ModelMipInfo &mmi, MappingSurface &ms)
|
||||||
|
|
||||||
// create elements
|
// create elements
|
||||||
ms.ms_ctSrfEl = ctTriangles*3;
|
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
|
// dump all triangles
|
||||||
//_RPT0(_CRT_WARN, "Result:\n");
|
//_RPT0(_CRT_WARN, "Result:\n");
|
||||||
INDEX iel = 0;
|
INDEX iel = 0;
|
||||||
|
@ -587,7 +587,7 @@ static void SetCol(void)
|
||||||
_icol = (_icol+1)%_ctcol;
|
_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
|
// set strip color
|
||||||
pglDisableClientState( GL_COLOR_ARRAY);
|
pglDisableClientState( GL_COLOR_ARRAY);
|
||||||
|
@ -603,9 +603,9 @@ static void DrawStrips( const INDEX ct, const INDEX *pai)
|
||||||
|
|
||||||
while( i<ct/3)
|
while( i<ct/3)
|
||||||
{
|
{
|
||||||
INDEX i0 = pai[i*3+0];
|
INDEX_T i0 = pai[i*3+0];
|
||||||
INDEX i1 = pai[i*3+1];
|
INDEX_T i1 = pai[i*3+1];
|
||||||
INDEX i2 = pai[i*3+2];
|
INDEX_T i2 = pai[i*3+2];
|
||||||
ctMaxTriPerStrip = Max( ctMaxTriPerStrip, INDEX(iInStrip));
|
ctMaxTriPerStrip = Max( ctMaxTriPerStrip, INDEX(iInStrip));
|
||||||
|
|
||||||
if( iInStrip==0) {
|
if( iInStrip==0) {
|
||||||
|
@ -759,7 +759,7 @@ static BOOL IsModelInHaze( FLOAT3D &vMin, FLOAT3D &vMax)
|
||||||
|
|
||||||
|
|
||||||
// render all pending elements
|
// render all pending elements
|
||||||
static void FlushElements( INDEX ctElem, INDEX *pai)
|
static void FlushElements( INDEX ctElem, INDEX_T *pai)
|
||||||
{
|
{
|
||||||
ASSERT(ctElem>0);
|
ASSERT(ctElem>0);
|
||||||
// choose rendering mode
|
// choose rendering mode
|
||||||
|
@ -2106,6 +2106,37 @@ vtxRest:
|
||||||
vtxEnd:
|
vtxEnd:
|
||||||
pop ebx
|
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
|
#else
|
||||||
// setup texcoord array
|
// setup texcoord array
|
||||||
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) {
|
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) {
|
||||||
|
|
|
@ -262,7 +262,7 @@ void CRenderer::SetupFogAndHaze(void)
|
||||||
// if viewer is not in haze
|
// if viewer is not in haze
|
||||||
if( !re_bViewerInHaze) {
|
if( !re_bViewerInHaze) {
|
||||||
// if viewer is in this sector
|
// if viewer is in this sector
|
||||||
if( bsc.bsc_bspBSPTree.TestSphere(re_vdViewSphere, 0.01)>=0) {
|
if( bsc.bsc_bspBSPTree.TestSphere(re_vdViewSphere, 0.01f)>=0) {
|
||||||
// mark that viewer is in haze
|
// mark that viewer is in haze
|
||||||
re_bViewerInHaze = TRUE;
|
re_bViewerInHaze = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,7 +662,7 @@ void CRenderer::AddZoningSectorsAroundEntity(CEntity *pen, const FLOAT3D &vEyesP
|
||||||
ASSERT(!(pen->en_ulFlags&ENF_ZONING));
|
ASSERT(!(pen->en_ulFlags&ENF_ZONING));
|
||||||
|
|
||||||
// make parameters for minimum sphere to add
|
// make parameters for minimum sphere to add
|
||||||
re_vdViewSphere = FLOATtoDOUBLE(vEyesPos);
|
re_vdViewSphere = vEyesPos;
|
||||||
re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f;
|
re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f;
|
||||||
|
|
||||||
CListHead lhToAdd;
|
CListHead lhToAdd;
|
||||||
|
@ -751,7 +751,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear)
|
||||||
FLOAT3D vSphereCenter = boxNear.Center();
|
FLOAT3D vSphereCenter = boxNear.Center();
|
||||||
|
|
||||||
re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f;
|
re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f;
|
||||||
re_vdViewSphere = FLOATtoDOUBLE(vSphereCenter);
|
re_vdViewSphere = vSphereCenter;
|
||||||
|
|
||||||
// for all entities in world
|
// for all entities in world
|
||||||
FOREACHINDYNAMICCONTAINER(re_pwoWorld->wo_cenEntities, CEntity, iten) {
|
FOREACHINDYNAMICCONTAINER(re_pwoWorld->wo_cenEntities, CEntity, iten) {
|
||||||
|
@ -792,7 +792,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear)
|
||||||
&&!((itbsc->bsc_ulFlags&BSCF_HIDDEN) && !re_bRenderingShadows)) {
|
&&!((itbsc->bsc_ulFlags&BSCF_HIDDEN) && !re_bRenderingShadows)) {
|
||||||
// if the sphere is inside the sector
|
// if the sphere is inside the sector
|
||||||
if (itbsc->bsc_bspBSPTree.TestSphere(
|
if (itbsc->bsc_bspBSPTree.TestSphere(
|
||||||
FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) {
|
vSphereCenter, fSphereRadius)>=0) {
|
||||||
|
|
||||||
// add that sector to active sectors
|
// add that sector to active sectors
|
||||||
AddActiveSector(itbsc.Current());
|
AddActiveSector(itbsc.Current());
|
||||||
|
|
|
@ -287,8 +287,8 @@ public:
|
||||||
CEntity *re_penViewer; // entity that is viewed from
|
CEntity *re_penViewer; // entity that is viewed from
|
||||||
CDynamicContainer<CScreenPolygon> *re_pcspoViewPolygons; // polygons that is viewed from (for mirrors)
|
CDynamicContainer<CScreenPolygon> *re_pcspoViewPolygons; // polygons that is viewed from (for mirrors)
|
||||||
CAnyProjection3D re_prProjection; // projection to viewer space
|
CAnyProjection3D re_prProjection; // projection to viewer space
|
||||||
DOUBLE3D re_vdViewSphere;
|
FLOAT3D re_vdViewSphere;
|
||||||
DOUBLE re_dViewSphereR;
|
FLOAT re_dViewSphereR;
|
||||||
|
|
||||||
// used for fixing problems with extra trapezoids generated on t-junctions
|
// used for fixing problems with extra trapezoids generated on t-junctions
|
||||||
FLOAT re_fEdgeOffsetI;
|
FLOAT re_fEdgeOffsetI;
|
||||||
|
|
2
Sources/Engine/Ska/Mesh.h
Normal file → Executable file
2
Sources/Engine/Ska/Mesh.h
Normal file → Executable file
|
@ -117,7 +117,7 @@ struct ENGINE_API MeshSurface
|
||||||
|
|
||||||
struct ENGINE_API MeshTriangle
|
struct ENGINE_API MeshTriangle
|
||||||
{
|
{
|
||||||
INDEX iVertex[3];
|
INDEX_T iVertex[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline CTStream &operator>>(CTStream &strm, MeshTriangle &mt)
|
static inline CTStream &operator>>(CTStream &strm, MeshTriangle &mt)
|
||||||
|
|
25
Sources/Engine/Ska/RMRender.cpp
Normal file → Executable file
25
Sources/Engine/Ska/RMRender.cpp
Normal file → Executable file
|
@ -767,7 +767,7 @@ void RM_RenderGround(CTextureObject &to)
|
||||||
|
|
||||||
GFXVertex vBoxVtxs[4];
|
GFXVertex vBoxVtxs[4];
|
||||||
GFXTexCoord tcBoxTex[4];
|
GFXTexCoord tcBoxTex[4];
|
||||||
INDEX aiIndices[6];
|
INDEX_T aiIndices[6] = {0, 2, 1, 0 ,3 ,2};
|
||||||
|
|
||||||
// set ground vertices
|
// set ground vertices
|
||||||
vBoxVtxs[0].x = vVtx(1); vBoxVtxs[0].y = vVtx(2); vBoxVtxs[0].z = -vVtx(3);
|
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++) {
|
for(INDEX ivx=0;ivx<4;ivx++) {
|
||||||
TransformVertex(vBoxVtxs[ivx],_mAbsToViewer);
|
TransformVertex(vBoxVtxs[ivx],_mAbsToViewer);
|
||||||
}
|
}
|
||||||
aiIndices[0] = 0; aiIndices[1] = 2; aiIndices[2] = 1;
|
/*aiIndices[0] = 0; aiIndices[1] = 2; aiIndices[2] = 1;
|
||||||
aiIndices[3] = 0; aiIndices[4] = 3; aiIndices[5] = 2;
|
aiIndices[3] = 0; aiIndices[4] = 3; aiIndices[5] = 2;*/
|
||||||
|
|
||||||
gfxSetVertexArray(vBoxVtxs,4);
|
gfxSetVertexArray(vBoxVtxs,4);
|
||||||
gfxSetTexCoordArray(tcBoxTex, FALSE);
|
gfxSetTexCoordArray(tcBoxTex, FALSE);
|
||||||
|
@ -852,8 +852,21 @@ static void RenderBox(FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col)
|
||||||
for(INDEX iwx=0;iwx<8;iwx++) {
|
for(INDEX iwx=0;iwx<8;iwx++) {
|
||||||
TransformVertex(vBoxVtxs[iwx],_mObjToViewStretch);
|
TransformVertex(vBoxVtxs[iwx],_mObjToViewStretch);
|
||||||
}
|
}
|
||||||
INDEX aiIndices[36];
|
INDEX_T aiIndices[36] = {
|
||||||
aiIndices[ 0] = 0; aiIndices[ 1] = 3; aiIndices[ 2] = 1;
|
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[ 3] = 0; aiIndices[ 4] = 2; aiIndices[ 5] = 3;
|
||||||
aiIndices[ 6] = 5; aiIndices[ 7] = 1; aiIndices[ 8] = 3;
|
aiIndices[ 6] = 5; aiIndices[ 7] = 1; aiIndices[ 8] = 3;
|
||||||
aiIndices[ 9] = 7; aiIndices[10] = 5; aiIndices[11] = 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[24] = 5; aiIndices[25] = 0; aiIndices[26] = 1;
|
||||||
aiIndices[27] = 5; aiIndices[28] = 4; aiIndices[29] = 0;
|
aiIndices[27] = 5; aiIndices[28] = 4; aiIndices[29] = 0;
|
||||||
aiIndices[30] = 4; aiIndices[31] = 5; aiIndices[32] = 7;
|
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);
|
gfxSetVertexArray(vBoxVtxs,8);
|
||||||
gfxDrawElements(36,aiIndices);
|
gfxDrawElements(36,aiIndices);
|
||||||
|
|
2
Sources/Engine/Ska/RMRenderMask.cpp
Normal file → Executable file
2
Sources/Engine/Ska/RMRenderMask.cpp
Normal file → Executable file
|
@ -40,7 +40,7 @@ extern void InternalShader_Mask(void)
|
||||||
INDEX ctIdx = shaGetIndexCount();
|
INDEX ctIdx = shaGetIndexCount();
|
||||||
INDEX ctVtx = shaGetVertexCount();
|
INDEX ctVtx = shaGetVertexCount();
|
||||||
if( ctIdx==0 || ctVtx==0) return;
|
if( ctIdx==0 || ctVtx==0) return;
|
||||||
INDEX *pidx = shaGetIndexArray();
|
INDEX_T *pidx = shaGetIndexArray();
|
||||||
GFXVertex4 *pvtx = shaGetVertexArray();
|
GFXVertex4 *pvtx = shaGetVertexArray();
|
||||||
GFXTexCoord *ptex = shaGetUVMap(0);
|
GFXTexCoord *ptex = shaGetUVMap(0);
|
||||||
CTextureObject *pto = shaGetTexture(0);
|
CTextureObject *pto = shaGetTexture(0);
|
||||||
|
|
309
Sources/Engine/Templates/BSP.cpp
Normal file → Executable file
309
Sources/Engine/Templates/BSP.cpp
Normal file → Executable file
|
@ -506,6 +506,310 @@ FLOAT BSPNode<Type, iDimensions>::TestSphere(const Vector<Type, iDimensions> &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<double, 3>::TestSphere_hack(const FLOAT *params) const
|
||||||
|
{
|
||||||
|
const BSPNode<double, 3> *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<double, 3>::TestSphere(const Vector<double, 3> &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<float, 3>::TestSphere_hack(const FLOAT *params) const
|
||||||
|
{
|
||||||
|
const BSPNode<float, 3> *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<float, 3>::TestSphere(const Vector<float, 3> &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) */
|
/* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */
|
||||||
template<class Type, int iDimensions>
|
template<class Type, int iDimensions>
|
||||||
FLOAT BSPNode<Type, iDimensions>::TestBox(const OBBox<Type> &box) const
|
FLOAT BSPNode<Type, iDimensions>::TestBox(const OBBox<Type> &box) const
|
||||||
|
@ -1210,7 +1514,10 @@ void BSPTree<Type, iDimensions>::Read_t(CTStream &strm) // throw char *
|
||||||
BSPNode<Type, iDimensions> &bn = bt_abnNodes[iNode];
|
BSPNode<Type, iDimensions> &bn = bt_abnNodes[iNode];
|
||||||
// read it from disk
|
// read it from disk
|
||||||
//strm.Read_t(&(Plane<Type, iDimensions>&)bn, sizeof(Plane<Type, iDimensions>));
|
//strm.Read_t(&(Plane<Type, iDimensions>&)bn, sizeof(Plane<Type, iDimensions>));
|
||||||
strm >> ((Plane<Type, iDimensions>&)bn);
|
//strm >> ((Plane<Type, iDimensions>&)bn);
|
||||||
|
Plane<DOUBLE, iDimensions> tmp;
|
||||||
|
strm >> tmp;
|
||||||
|
((Plane<FLOAT, iDimensions> &)bn) = DOUBLEtoFLOAT(tmp);
|
||||||
|
|
||||||
strm>>(INDEX&)bn.bn_bnlLocation;
|
strm>>(INDEX&)bn.bn_bnlLocation;
|
||||||
|
|
||||||
|
|
4
Sources/Engine/Templates/BSP.h
Normal file → Executable file
4
Sources/Engine/Templates/BSP.h
Normal file → Executable file
|
@ -60,9 +60,9 @@ public:
|
||||||
Type &tMin,
|
Type &tMin,
|
||||||
Type &tMax) const;
|
Type &tMax) const;
|
||||||
/* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */
|
/* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */
|
||||||
FLOAT TestSphere(const Vector<Type, iDimensions> &vSphereCenter, Type tSphereRadius) const;
|
FLOAT FASTMATH TestSphere(const Vector<Type, iDimensions> &vSphereCenter, Type tSphereRadius) const;
|
||||||
/* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */
|
/* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */
|
||||||
FLOAT TestBox(const OBBox<Type> &box) const;
|
FLOAT FASTMATH TestBox(const OBBox<Type> &box) const;
|
||||||
/* Read/write entire bsp tree to disk. */
|
/* Read/write entire bsp tree to disk. */
|
||||||
void Read_t(CTStream &strm); // throw char *
|
void Read_t(CTStream &strm); // throw char *
|
||||||
void Write_t(CTStream &strm); // throw char *
|
void Write_t(CTStream &strm); // throw char *
|
||||||
|
|
|
@ -169,6 +169,7 @@ public:
|
||||||
|
|
||||||
/* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */
|
/* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */
|
||||||
FLOAT TestSphere(const Vector<Type, iDimensions> &vSphereCenter, Type tSphereRadius) const;
|
FLOAT TestSphere(const Vector<Type, iDimensions> &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) */
|
/* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */
|
||||||
FLOAT TestBox(const OBBox<Type> &box) const;
|
FLOAT TestBox(const OBBox<Type> &box) const;
|
||||||
};
|
};
|
||||||
|
|
4
Sources/Engine/Terrain/ArrayHolder.h
Normal file → Executable file
4
Sources/Engine/Terrain/ArrayHolder.h
Normal file → Executable file
|
@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
struct TileLayer
|
struct TileLayer
|
||||||
{
|
{
|
||||||
CStaticStackArray<INDEX> tl_auiIndices; // Array of indices for one layer
|
CStaticStackArray<INDEX_T> tl_auiIndices; // Array of indices for one layer
|
||||||
CStaticStackArray<GFXColor> tl_acColors; // Array of colors for one layer
|
CStaticStackArray<GFXColor> tl_acColors; // Array of colors for one layer
|
||||||
CStaticStackArray<GFXTexCoord> tl_atcTexCoords; // Array of texcoords for one layer
|
CStaticStackArray<GFXTexCoord> tl_atcTexCoords; // Array of texcoords for one layer
|
||||||
CStaticStackArray<GFXVertex> tl_avVertices; // Array of vertices for one layer (used only if tile layer)
|
CStaticStackArray<GFXVertex> tl_avVertices; // Array of vertices for one layer (used only if tile layer)
|
||||||
|
@ -48,7 +48,7 @@ struct TileArrays
|
||||||
CStaticStackArray<GFXTexCoord> ta_auvTexCoords; // Array of texcoords for one tile (not used in highest lod)
|
CStaticStackArray<GFXTexCoord> ta_auvTexCoords; // Array of texcoords for one tile (not used in highest lod)
|
||||||
CStaticStackArray<GFXTexCoord> ta_auvShadowMap; // Array of texcoords for shadow map
|
CStaticStackArray<GFXTexCoord> ta_auvShadowMap; // Array of texcoords for shadow map
|
||||||
CStaticStackArray<GFXTexCoord> ta_auvDetailMap; // Array of texcoords for detail map
|
CStaticStackArray<GFXTexCoord> ta_auvDetailMap; // Array of texcoords for detail map
|
||||||
CStaticStackArray<INDEX> ta_auiIndices; // Array of indices for one tile
|
CStaticStackArray<INDEX_T> ta_auiIndices; // Array of indices for one tile
|
||||||
CStaticStackArray<TileLayer> ta_atlLayers; // Array if layers per tile (used only in highest lod)
|
CStaticStackArray<TileLayer> ta_atlLayers; // Array if layers per tile (used only in highest lod)
|
||||||
CTextureData *ta_ptdTopMap; // Pointer to tile top map
|
CTextureData *ta_ptdTopMap; // Pointer to tile top map
|
||||||
};
|
};
|
||||||
|
|
2
Sources/Engine/Terrain/TerrainEditing.cpp
Normal file → Executable file
2
Sources/Engine/Terrain/TerrainEditing.cpp
Normal file → Executable file
|
@ -150,7 +150,7 @@ void ShowSelectionInternal(CTerrain *ptrTerrain, Rect &rcExtract, CTextureData *
|
||||||
bboxSelection.maxvect(2) = bboxAllTerrain.maxvect(2);
|
bboxSelection.maxvect(2) = bboxAllTerrain.maxvect(2);
|
||||||
|
|
||||||
GFXVertex *pavVertices;
|
GFXVertex *pavVertices;
|
||||||
INDEX *paiIndices;
|
INDEX_T *paiIndices;
|
||||||
INDEX ctVertices;
|
INDEX ctVertices;
|
||||||
INDEX ctIndices;
|
INDEX ctIndices;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern CTerrain *_ptrTerrain; // Current terrain
|
||||||
static FLOAT3D _vHitLocation = FLOAT3D(-100,-100,-100);
|
static FLOAT3D _vHitLocation = FLOAT3D(-100,-100,-100);
|
||||||
|
|
||||||
CStaticStackArray<GFXVertex4> _avExtVertices;
|
CStaticStackArray<GFXVertex4> _avExtVertices;
|
||||||
CStaticStackArray<INDEX> _aiExtIndices;
|
CStaticStackArray<INDEX_T> _aiExtIndices;
|
||||||
CStaticStackArray<GFXColor> _aiExtColors;
|
CStaticStackArray<GFXColor> _aiExtColors;
|
||||||
CStaticStackArray<INDEX> _aiHitTiles;
|
CStaticStackArray<INDEX> _aiHitTiles;
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget,
|
||||||
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex];
|
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex];
|
||||||
|
|
||||||
GFXVertex *pavVertices;
|
GFXVertex *pavVertices;
|
||||||
INDEX *paiIndices;
|
INDEX_T *paiIndices;
|
||||||
INDEX ctVertices;
|
INDEX ctVertices;
|
||||||
INDEX ctIndices;
|
INDEX ctIndices;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget,
|
||||||
|
|
||||||
// for each triangle
|
// for each triangle
|
||||||
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
||||||
INDEX *pind = &paiIndices[iTri];
|
INDEX_T *pind = &paiIndices[iTri];
|
||||||
GFXVertex &v0 = pavVertices[pind[0]];
|
GFXVertex &v0 = pavVertices[pind[0]];
|
||||||
GFXVertex &v1 = pavVertices[pind[1]];
|
GFXVertex &v1 = pavVertices[pind[1]];
|
||||||
GFXVertex &v2 = pavVertices[pind[2]];
|
GFXVertex &v2 = pavVertices[pind[2]];
|
||||||
|
@ -291,7 +291,7 @@ FLOAT3D _vHitExact; // TEMP
|
||||||
#pragma message(">> Remove Rect from ExtractPolygonsInBox")
|
#pragma message(">> Remove Rect from ExtractPolygonsInBox")
|
||||||
// Extract polygons in given box and returns clipped rectangle
|
// Extract polygons in given box and returns clipped rectangle
|
||||||
Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract, GFXVertex4 **pavVtx,
|
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);
|
ASSERT(ptrTerrain!=NULL);
|
||||||
|
|
||||||
|
@ -310,10 +310,10 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract
|
||||||
if(!bFixSize) {
|
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
|
// 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 __arm__
|
||||||
#ifdef PANDORA
|
#ifdef PLATFORM_PANDORA
|
||||||
#define Isinf(a) (((*(unsigned int*)&a)&0x7fffffff)==0x7f800000)
|
#define Isinf(a) (((*(unsigned int*)&a)&0x7fffffff)==0x7f800000)
|
||||||
#else
|
#else
|
||||||
#define Isinf insif
|
#define Isinf isinff
|
||||||
#endif
|
#endif
|
||||||
rc.rc_iLeft = (Isinf(bbox.minvect(1)))?(INDEX)0:Clamp((INDEX)(bbox.minvect(1)-0),(INDEX)0,ptrTerrain->tr_pixHeightMapWidth);
|
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);
|
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);
|
_aiExtIndices.Push(ctIndices);
|
||||||
|
|
||||||
GFXVertex4 *pavVertices = &_avExtVertices[0];
|
GFXVertex4 *pavVertices = &_avExtVertices[0];
|
||||||
INDEX *pauiIndices = &_aiExtIndices[0];
|
INDEX_T *pauiIndices = &_aiExtIndices[0];
|
||||||
|
|
||||||
// for each row
|
// for each row
|
||||||
INDEX iy, ix;
|
INDEX iy, ix;
|
||||||
|
@ -456,7 +456,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx,
|
void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx,
|
||||||
INDEX **paiInd, INDEX &ctVtx,INDEX &ctInd)
|
INDEX_T **paiInd, INDEX &ctVtx,INDEX &ctInd)
|
||||||
{
|
{
|
||||||
_avExtVertices.PopAll();
|
_avExtVertices.PopAll();
|
||||||
_aiExtIndices.PopAll();
|
_aiExtIndices.PopAll();
|
||||||
|
@ -497,7 +497,7 @@ void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx,
|
||||||
puwHeight+=iStepY;
|
puwHeight+=iStepY;
|
||||||
}
|
}
|
||||||
|
|
||||||
INDEX *pauiIndices = &_aiExtIndices[0];
|
INDEX_T *pauiIndices = &_aiExtIndices[0];
|
||||||
INDEX ivx=0;
|
INDEX ivx=0;
|
||||||
//INDEX ind=0;
|
//INDEX ind=0;
|
||||||
INDEX iFacing=iFirstHeight;
|
INDEX iFacing=iFirstHeight;
|
||||||
|
|
4
Sources/Engine/Terrain/TerrainMisc.h
Normal file → Executable file
4
Sources/Engine/Terrain/TerrainMisc.h
Normal file → Executable file
|
@ -22,10 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <Engine/Terrain/Terrain.h>
|
#include <Engine/Terrain/Terrain.h>
|
||||||
// Extract polygons in given box and returns clipped rectangle
|
// Extract polygons in given box and returns clipped rectangle
|
||||||
Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bbox, GFXVertex4 **pavVtx,
|
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,
|
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
|
// check whether a polygon is below given point, but not too far away
|
||||||
|
|
14
Sources/Engine/Terrain/TerrainRayCasting.cpp
Normal file → Executable file
14
Sources/Engine/Terrain/TerrainRayCasting.cpp
Normal file → Executable file
|
@ -32,7 +32,7 @@ static FLOATplane3D _plHitPlane; // hit plane
|
||||||
|
|
||||||
// TEMP
|
// TEMP
|
||||||
static CStaticStackArray<GFXVertex> _avRCVertices;
|
static CStaticStackArray<GFXVertex> _avRCVertices;
|
||||||
static CStaticStackArray<INDEX> _aiRCIndices;
|
static CStaticStackArray<INDEX_T> _aiRCIndices;
|
||||||
static FLOAT3D _vHitBegin;
|
static FLOAT3D _vHitBegin;
|
||||||
static FLOAT3D _vHitEnd;
|
static FLOAT3D _vHitEnd;
|
||||||
static FLOAT _fDistance;
|
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].y<=_fMaxHeight || pvx[2].y<=_fMinHeight || pvx[1].y<=_fMinHeight) &&
|
||||||
((pvx[0].shade + pvx[2].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) {
|
((pvx[0].shade + pvx[2].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) {
|
||||||
// Add this triangle
|
// Add this triangle
|
||||||
INDEX *pind = _aiRCIndices.Push(3);
|
INDEX_T *pind = _aiRCIndices.Push(3);
|
||||||
pind[0] = ctVertices+0;
|
pind[0] = ctVertices+0;
|
||||||
pind[1] = ctVertices+2;
|
pind[1] = ctVertices+2;
|
||||||
pind[2] = ctVertices+1;
|
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].y<=_fMaxHeight || pvx[2].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight) &&
|
||||||
((pvx[1].shade + pvx[2].shade + pvx[3].shade == 255*3) | _bHitInvisibleTris)) {
|
((pvx[1].shade + pvx[2].shade + pvx[3].shade == 255*3) | _bHitInvisibleTris)) {
|
||||||
// Add this triangle
|
// Add this triangle
|
||||||
INDEX *pind = _aiRCIndices.Push(3);
|
INDEX_T *pind = _aiRCIndices.Push(3);
|
||||||
pind[0] = ctVertices+1;
|
pind[0] = ctVertices+1;
|
||||||
pind[1] = ctVertices+2;
|
pind[1] = ctVertices+2;
|
||||||
pind[2] = ctVertices+3;
|
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].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight || pvx[0].y<=_fMaxHeight) &&
|
||||||
((pvx[2].shade + pvx[3].shade + pvx[0].shade == 255*3) | _bHitInvisibleTris)) {
|
((pvx[2].shade + pvx[3].shade + pvx[0].shade == 255*3) | _bHitInvisibleTris)) {
|
||||||
// Add this triangle
|
// Add this triangle
|
||||||
INDEX *pind = _aiRCIndices.Push(3);
|
INDEX_T *pind = _aiRCIndices.Push(3);
|
||||||
pind[0] = ctVertices+2;
|
pind[0] = ctVertices+2;
|
||||||
pind[1] = ctVertices+3;
|
pind[1] = ctVertices+3;
|
||||||
pind[2] = ctVertices+0;
|
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].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight || pvx[1].y<=_fMaxHeight) &&
|
||||||
((pvx[0].shade + pvx[3].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) {
|
((pvx[0].shade + pvx[3].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) {
|
||||||
// Add this triangle
|
// Add this triangle
|
||||||
INDEX *pind = _aiRCIndices.Push(3);
|
INDEX_T *pind = _aiRCIndices.Push(3);
|
||||||
pind[0] = ctVertices+0;
|
pind[0] = ctVertices+0;
|
||||||
pind[1] = ctVertices+3;
|
pind[1] = ctVertices+3;
|
||||||
pind[2] = ctVertices+1;
|
pind[2] = ctVertices+1;
|
||||||
|
@ -135,10 +135,10 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz)
|
||||||
return fDistance;
|
return fDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
INDEX *paiIndices = &_aiRCIndices[_aiRCIndices.Count() - ctIndices];
|
INDEX_T *paiIndices = &_aiRCIndices[_aiRCIndices.Count() - ctIndices];
|
||||||
// for each triangle
|
// for each triangle
|
||||||
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
||||||
INDEX *pind = &paiIndices[iTri];
|
INDEX_T *pind = &paiIndices[iTri];
|
||||||
GFXVertex &v0 = pavVertices[pind[0]];
|
GFXVertex &v0 = pavVertices[pind[0]];
|
||||||
GFXVertex &v1 = pavVertices[pind[1]];
|
GFXVertex &v1 = pavVertices[pind[1]];
|
||||||
GFXVertex &v2 = pavVertices[pind[2]];
|
GFXVertex &v2 = pavVertices[pind[2]];
|
||||||
|
|
4
Sources/Engine/Terrain/TerrainRayCasting.h
Normal file → Executable file
4
Sources/Engine/Terrain/TerrainRayCasting.h
Normal file → Executable file
|
@ -19,11 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FLOAT TestRayCastHit(CTerrain *ptrTerrain, const FLOATmatrix3D &mRotation, const FLOAT3D &vPosition,
|
FLOAT FASTMATH TestRayCastHit(CTerrain *ptrTerrain, const FLOATmatrix3D &mRotation, const FLOAT3D &vPosition,
|
||||||
const FLOAT3D &vOrigin, const FLOAT3D &vTarget,const FLOAT fOldDistance,
|
const FLOAT3D &vOrigin, const FLOAT3D &vTarget,const FLOAT fOldDistance,
|
||||||
const BOOL bHitInvisibleTris);
|
const BOOL bHitInvisibleTris);
|
||||||
|
|
||||||
FLOAT TestRayCastHit(CTerrain *ptrTerrain, const FLOATmatrix3D &mRotation, const FLOAT3D &vPosition,
|
FLOAT FASTMATH TestRayCastHit(CTerrain *ptrTerrain, const FLOATmatrix3D &mRotation, const FLOAT3D &vPosition,
|
||||||
const FLOAT3D &vOrigin, const FLOAT3D &vTarget,const FLOAT fOldDistance,
|
const FLOAT3D &vOrigin, const FLOAT3D &vTarget,const FLOAT fOldDistance,
|
||||||
const BOOL bHitInvisibleTris, FLOATplane3D &plHitPlane, FLOAT3D &vHitPoint);
|
const BOOL bHitInvisibleTris, FLOATplane3D &plHitPlane, FLOAT3D &vHitPoint);
|
||||||
#endif
|
#endif
|
||||||
|
|
16
Sources/Engine/Terrain/TerrainRender.cpp
Normal file → Executable file
16
Sources/Engine/Terrain/TerrainRender.cpp
Normal file → Executable file
|
@ -46,7 +46,7 @@ CStaticStackArray<GFXVertex4> _avLerpedTileLayerVertices;
|
||||||
|
|
||||||
// Arrays for batch rendering of tiles is lowest mip
|
// Arrays for batch rendering of tiles is lowest mip
|
||||||
static CStaticStackArray<GFXVertex4> _avDelayedVertices;
|
static CStaticStackArray<GFXVertex4> _avDelayedVertices;
|
||||||
static CStaticStackArray<INDEX> _aiDelayedIndices;
|
static CStaticStackArray<INDEX_T> _aiDelayedIndices;
|
||||||
static CStaticStackArray<GFXTexCoord> _auvDelayedTexCoords;
|
static CStaticStackArray<GFXTexCoord> _auvDelayedTexCoords;
|
||||||
static CStaticStackArray<GFXTexCoord> _auvDelayedShadowMapTC;
|
static CStaticStackArray<GFXTexCoord> _auvDelayedShadowMapTC;
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ static void RenderBatchedTiles(void)
|
||||||
GFXVertex4 *pavVertices = &_avDelayedVertices[0];
|
GFXVertex4 *pavVertices = &_avDelayedVertices[0];
|
||||||
GFXTexCoord *pauvTexCoords = &_auvDelayedTexCoords[0];
|
GFXTexCoord *pauvTexCoords = &_auvDelayedTexCoords[0];
|
||||||
GFXTexCoord *pauvShadowMapTC = &_auvDelayedShadowMapTC[0];
|
GFXTexCoord *pauvShadowMapTC = &_auvDelayedShadowMapTC[0];
|
||||||
INDEX *paiIndices = &_aiDelayedIndices[0];
|
INDEX_T *paiIndices = &_aiDelayedIndices[0];
|
||||||
INDEX ctVertices = _avDelayedVertices.Count();
|
INDEX ctVertices = _avDelayedVertices.Count();
|
||||||
INDEX ctIndices = _aiDelayedIndices.Count();
|
INDEX ctIndices = _aiDelayedIndices.Count();
|
||||||
|
|
||||||
|
@ -826,12 +826,12 @@ static void BatchTile(INDEX itt)
|
||||||
GFXVertex4 *pavVertices = &tt.GetVertices()[0];
|
GFXVertex4 *pavVertices = &tt.GetVertices()[0];
|
||||||
GFXTexCoord *pauvTexCoords = &tt.GetTexCoords()[0];
|
GFXTexCoord *pauvTexCoords = &tt.GetTexCoords()[0];
|
||||||
GFXTexCoord *pauvShadowMapTC = &tt.GetShadowMapTC()[0];
|
GFXTexCoord *pauvShadowMapTC = &tt.GetShadowMapTC()[0];
|
||||||
INDEX *paiIndices = &tt.GetIndices()[0];
|
INDEX_T *paiIndices = &tt.GetIndices()[0];
|
||||||
|
|
||||||
GFXVertex4 *pavDelVertices = _avDelayedVertices.Push(9);
|
GFXVertex4 *pavDelVertices = _avDelayedVertices.Push(9);
|
||||||
GFXTexCoord *pauvDelTexCoords = _auvDelayedTexCoords.Push(9);
|
GFXTexCoord *pauvDelTexCoords = _auvDelayedTexCoords.Push(9);
|
||||||
GFXTexCoord *pauvDelShadowMapTC = _auvDelayedShadowMapTC.Push(9);
|
GFXTexCoord *pauvDelShadowMapTC = _auvDelayedShadowMapTC.Push(9);
|
||||||
INDEX *paiDelIndices = _aiDelayedIndices.Push(24);
|
INDEX_T *paiDelIndices = _aiDelayedIndices.Push(24);
|
||||||
|
|
||||||
// for each vertex in tile
|
// for each vertex in tile
|
||||||
for(INDEX ivx=0;ivx<9;ivx++) {
|
for(INDEX ivx=0;ivx<9;ivx++) {
|
||||||
|
@ -891,7 +891,7 @@ static void RenderFogLayer(INDEX itt)
|
||||||
_fFogAddH = (_fog_vHDirAbs % vObjPosition) + _fog_fp.fp_fH3;
|
_fFogAddH = (_fog_vHDirAbs % vObjPosition) + _fog_fp.fp_fH3;
|
||||||
|
|
||||||
GFXVertex *pvVtx;
|
GFXVertex *pvVtx;
|
||||||
INDEX *piIndices;
|
INDEX_T *piIndices;
|
||||||
INDEX ctVertices;
|
INDEX ctVertices;
|
||||||
INDEX ctIndices;
|
INDEX ctIndices;
|
||||||
// if this is tile
|
// if this is tile
|
||||||
|
@ -947,7 +947,7 @@ static void RenderHazeLayer(INDEX itt)
|
||||||
_fHazeAdd += _vViewer(3) * (vObjPosition(3) - _aprProjection->pr_vViewerPosition(3));
|
_fHazeAdd += _vViewer(3) * (vObjPosition(3) - _aprProjection->pr_vViewerPosition(3));
|
||||||
|
|
||||||
GFXVertex *pvVtx;
|
GFXVertex *pvVtx;
|
||||||
INDEX *piIndices;
|
INDEX_T *piIndices;
|
||||||
INDEX ctVertices;
|
INDEX ctVertices;
|
||||||
INDEX ctIndices;
|
INDEX ctIndices;
|
||||||
// if this is tile
|
// if this is tile
|
||||||
|
@ -1103,7 +1103,7 @@ static void RenderTile(INDEX itt)
|
||||||
gfxSetTextureMatrix2(NULL);
|
gfxSetTextureMatrix2(NULL);
|
||||||
INDEX ctIndices = tt.GetIndices().Count();
|
INDEX ctIndices = tt.GetIndices().Count();
|
||||||
if(ctIndices>0) {
|
if(ctIndices>0) {
|
||||||
INDEX *paiIndices = &tt.GetIndices()[0];
|
INDEX_T *paiIndices = &tt.GetIndices()[0];
|
||||||
|
|
||||||
// if detail map exists
|
// if detail map exists
|
||||||
if(_ptrTerrain->tr_ptdDetailMap!=NULL) {
|
if(_ptrTerrain->tr_ptdDetailMap!=NULL) {
|
||||||
|
@ -1157,7 +1157,7 @@ static void RenderTile(INDEX itt)
|
||||||
if(_wrpWorldRenderPrefs.wrp_shtShadows!=CWorldRenderPrefs::SHT_NONE) {
|
if(_wrpWorldRenderPrefs.wrp_shtShadows!=CWorldRenderPrefs::SHT_NONE) {
|
||||||
gfxDepthFunc(GFX_EQUAL);
|
gfxDepthFunc(GFX_EQUAL);
|
||||||
INDEX ctIndices = tt.GetIndices().Count();
|
INDEX ctIndices = tt.GetIndices().Count();
|
||||||
INDEX *paiIndices = &tt.GetIndices()[0];
|
INDEX_T *paiIndices = &tt.GetIndices()[0];
|
||||||
|
|
||||||
gfxSetTextureWrapping(GFX_CLAMP,GFX_CLAMP);
|
gfxSetTextureWrapping(GFX_CLAMP,GFX_CLAMP);
|
||||||
gfxBlendFunc(GFX_DST_COLOR,GFX_SRC_COLOR);
|
gfxBlendFunc(GFX_DST_COLOR,GFX_SRC_COLOR);
|
||||||
|
|
12
Sources/Engine/Terrain/TerrainTile.cpp
Normal file → Executable file
12
Sources/Engine/Terrain/TerrainTile.cpp
Normal file → Executable file
|
@ -164,7 +164,7 @@ inline void CTerrainTile::AddTriangle(INDEX iind1,INDEX iind2,INDEX iind3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add one triangle
|
// Add one triangle
|
||||||
INDEX *pIndices = GetIndices().Push(3);
|
INDEX_T *pIndices = GetIndices().Push(3);
|
||||||
pIndices[0] = iind1;
|
pIndices[0] = iind1;
|
||||||
pIndices[1] = iind2;
|
pIndices[1] = iind2;
|
||||||
pIndices[2] = iind3;
|
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;
|
COLOR ul = ttl.tl_acColors[iind1].ub.a + ttl.tl_acColors[iind2].ub.a + ttl.tl_acColors[iind3].ub.a;
|
||||||
if(ul>0) {
|
if(ul>0) {
|
||||||
INDEX *pIndices = ttl.tl_auiIndices.Push(3);
|
INDEX_T *pIndices = ttl.tl_auiIndices.Push(3);
|
||||||
pIndices[0] = iind1;
|
pIndices[0] = iind1;
|
||||||
pIndices[1] = iind2;
|
pIndices[1] = iind2;
|
||||||
pIndices[2] = iind3;
|
pIndices[2] = iind3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
INDEX *pIndices = GetIndices().Push(3);
|
INDEX_T *pIndices = GetIndices().Push(3);
|
||||||
pIndices[0] = iind1;
|
pIndices[0] = iind1;
|
||||||
pIndices[1] = iind2;
|
pIndices[1] = iind2;
|
||||||
pIndices[2] = iind3;
|
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);
|
ASSERT(ttl.tl_avVertices.Count()==0 && ttl.tl_atcTexCoords.Count()==0 && ttl.tl_auiIndices.Count()==0);
|
||||||
GFXVertex *pvtx = ttl.tl_avVertices.Push(ctVertices);
|
GFXVertex *pvtx = ttl.tl_avVertices.Push(ctVertices);
|
||||||
GFXTexCoord *ptc = ttl.tl_atcTexCoords.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;
|
UBYTE *pubMask = tl.tl_aubColors;
|
||||||
|
|
||||||
INDEX ivx = 0;
|
INDEX ivx = 0;
|
||||||
|
@ -565,7 +565,7 @@ void CTerrainTile::UpdateQuadTreeNode()
|
||||||
// resize aabox for this node
|
// resize aabox for this node
|
||||||
FLOATaabbox3D bboxNewBox;
|
FLOATaabbox3D bboxNewBox;
|
||||||
GFXVertex4 *pavVertices;
|
GFXVertex4 *pavVertices;
|
||||||
INDEX *paiIndices;
|
INDEX_T *paiIndices;
|
||||||
INDEX ctVertices;
|
INDEX ctVertices;
|
||||||
INDEX ctIndices;
|
INDEX ctIndices;
|
||||||
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[tt_iIndex];
|
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[tt_iIndex];
|
||||||
|
@ -973,7 +973,7 @@ __forceinline CStaticStackArray<GFXTexCoord> &CTerrainTile::GetDetailTC() {
|
||||||
TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex];
|
TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex];
|
||||||
return ta.ta_auvDetailMap;
|
return ta.ta_auvDetailMap;
|
||||||
}
|
}
|
||||||
__forceinline CStaticStackArray<INDEX> &CTerrainTile::GetIndices() {
|
__forceinline CStaticStackArray<INDEX_T> &CTerrainTile::GetIndices() {
|
||||||
ASSERT(tt_iArrayIndex!=-1);
|
ASSERT(tt_iArrayIndex!=-1);
|
||||||
ASSERT(tt_iLod!=-1);
|
ASSERT(tt_iLod!=-1);
|
||||||
CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod];
|
CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod];
|
||||||
|
|
2
Sources/Engine/Terrain/TerrainTile.h
Normal file → Executable file
2
Sources/Engine/Terrain/TerrainTile.h
Normal file → Executable file
|
@ -58,7 +58,7 @@ public:
|
||||||
CStaticStackArray<GFXTexCoord> &GetTexCoords();
|
CStaticStackArray<GFXTexCoord> &GetTexCoords();
|
||||||
CStaticStackArray<GFXTexCoord> &GetShadowMapTC();
|
CStaticStackArray<GFXTexCoord> &GetShadowMapTC();
|
||||||
CStaticStackArray<GFXTexCoord> &GetDetailTC();
|
CStaticStackArray<GFXTexCoord> &GetDetailTC();
|
||||||
CStaticStackArray<INDEX> &GetIndices();
|
CStaticStackArray<INDEX_T> &GetIndices();
|
||||||
CStaticStackArray<TileLayer> &GetTileLayers();
|
CStaticStackArray<TileLayer> &GetTileLayers();
|
||||||
CTextureData *GetTopMap();
|
CTextureData *GetTopMap();
|
||||||
|
|
||||||
|
|
45
Sources/Engine/World/WorldCollision.cpp
Normal file → Executable file
45
Sources/Engine/World/WorldCollision.cpp
Normal file → Executable file
|
@ -350,8 +350,12 @@ void CClipMove::ClipMovingSphereToBrushPolygon(const CMovingSphere &msMoving,
|
||||||
// create an intersector
|
// create an intersector
|
||||||
CIntersector isIntersector(vHitPoint(iMajorAxis1), vHitPoint(iMajorAxis2));
|
CIntersector isIntersector(vHitPoint(iMajorAxis1), vHitPoint(iMajorAxis2));
|
||||||
// for all edges in the polygon
|
// for all edges in the polygon
|
||||||
FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge,
|
/*FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge,
|
||||||
itbpePolygonEdge) {
|
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!)
|
// get edge vertices (edge direction is irrelevant here!)
|
||||||
const FLOAT3D &vVertex0 = itbpePolygonEdge->bpe_pbedEdge->bed_pbvxVertex0->bvx_vRelative;
|
const FLOAT3D &vVertex0 = itbpePolygonEdge->bpe_pbedEdge->bed_pbvxVertex0->bvx_vRelative;
|
||||||
const FLOAT3D &vVertex1 = itbpePolygonEdge->bpe_pbedEdge->bed_pbvxVertex1->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
|
// 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!)
|
// get edge vertices (edge direction is important here!)
|
||||||
FLOAT3D vVertex0, vVertex1;
|
FLOAT3D vVertex0, vVertex1;
|
||||||
itbpe->GetVertexCoordinatesRelative(vVertex0, vVertex1);
|
itbpe->GetVertexCoordinatesRelative(vVertex0, vVertex1);
|
||||||
|
@ -509,7 +517,11 @@ void CClipMove::ClipMoveToTerrainPolygon(const FLOAT3D &v0, const FLOAT3D &v1, c
|
||||||
{
|
{
|
||||||
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON);
|
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON);
|
||||||
// for each sphere of entity A
|
// 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
|
// clip moving sphere to the polygon
|
||||||
ClipMovingSphereToTerrainPolygon(*itmsMoving, v0, v1, v2);
|
ClipMovingSphereToTerrainPolygon(*itmsMoving, v0, v1, v2);
|
||||||
}
|
}
|
||||||
|
@ -523,7 +535,11 @@ void CClipMove::ClipMoveToBrushPolygon(CBrushPolygon *pbpoPolygon)
|
||||||
{
|
{
|
||||||
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON);
|
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON);
|
||||||
// for each sphere of entity A
|
// 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
|
// clip moving sphere to the polygon
|
||||||
ClipMovingSphereToBrushPolygon(*itmsMoving, pbpoPolygon);
|
ClipMovingSphereToBrushPolygon(*itmsMoving, pbpoPolygon);
|
||||||
}
|
}
|
||||||
|
@ -869,10 +885,15 @@ void CClipMove::ClipToNonZoningSector(CBrushSector *pbsc)
|
||||||
CPhysicsProfile::PTI_CLIPTONONZONINGSECTOR, pbsc->bsc_abpoPolygons.Count());
|
CPhysicsProfile::PTI_CLIPTONONZONINGSECTOR, pbsc->bsc_abpoPolygons.Count());
|
||||||
|
|
||||||
// for each polygon in the sector
|
// 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 its bbox has no contact with bbox of movement path, or it is passable
|
||||||
if (!itbpo->bpo_boxBoundingBox.HasContactWith(cm_boxMovementPath)
|
__builtin_prefetch(&itbpo[1].bpo_ulFlags);
|
||||||
||(itbpo->bpo_ulFlags&BPOF_PASSABLE)) {
|
if ((itbpo->bpo_ulFlags&BPOF_PASSABLE)
|
||||||
|
||!itbpo->bpo_boxBoundingBox.HasContactWith(cm_boxMovementPath)) {
|
||||||
// skip it
|
// skip it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -893,7 +914,7 @@ void CClipMove::ClipToTerrain(CEntity *pen)
|
||||||
|
|
||||||
CTerrain &tr = *pen->en_ptrTerrain;
|
CTerrain &tr = *pen->en_ptrTerrain;
|
||||||
GFXVertex4 *pavVertices;
|
GFXVertex4 *pavVertices;
|
||||||
INDEX *paiIndices;
|
INDEX_T *paiIndices;
|
||||||
INDEX ctVertices,ctIndices;
|
INDEX ctVertices,ctIndices;
|
||||||
|
|
||||||
FLOAT3D vMin = cm_boxMovementPath.Min();
|
FLOAT3D vMin = cm_boxMovementPath.Min();
|
||||||
|
@ -920,9 +941,9 @@ void CClipMove::ClipToTerrain(CEntity *pen)
|
||||||
|
|
||||||
// for each triangle
|
// for each triangle
|
||||||
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
for(INDEX iTri=0;iTri<ctIndices;iTri+=3) {
|
||||||
INDEX &iind1 = paiIndices[iTri+0];
|
INDEX_T &iind1 = paiIndices[iTri+0];
|
||||||
INDEX &iind2 = paiIndices[iTri+1];
|
INDEX_T &iind2 = paiIndices[iTri+1];
|
||||||
INDEX &iind3 = paiIndices[iTri+2];
|
INDEX_T &iind3 = paiIndices[iTri+2];
|
||||||
FLOAT3D v0(pavVertices[iind1].x,pavVertices[iind1].y,pavVertices[iind1].z);
|
FLOAT3D v0(pavVertices[iind1].x,pavVertices[iind1].y,pavVertices[iind1].z);
|
||||||
FLOAT3D v1(pavVertices[iind2].x,pavVertices[iind2].y,pavVertices[iind2].z);
|
FLOAT3D v1(pavVertices[iind2].x,pavVertices[iind2].y,pavVertices[iind2].z);
|
||||||
FLOAT3D v2(pavVertices[iind3].x,pavVertices[iind3].y,pavVertices[iind3].z);
|
FLOAT3D v2(pavVertices[iind3].x,pavVertices[iind3].y,pavVertices[iind3].z);
|
||||||
|
|
|
@ -48,10 +48,10 @@ static inline void BoxToGrid(
|
||||||
FLOAT fMaxX = boxEntity.Max()(1);
|
FLOAT fMaxX = boxEntity.Max()(1);
|
||||||
FLOAT fMaxZ = boxEntity.Max()(3);
|
FLOAT fMaxZ = boxEntity.Max()(3);
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
#ifdef PANDORA
|
#ifdef PLATFORM_PANDORA
|
||||||
#define Isinf(a) (((*(unsigned int*)&a)&0x7fffffff)==0x7f800000)
|
#define Isinf(a) (((*(unsigned int*)&a)&0x7fffffff)==0x7f800000)
|
||||||
#else
|
#else
|
||||||
#define Isinf insif
|
#define Isinf isinff
|
||||||
#endif
|
#endif
|
||||||
iMinX = (Isinf(fMinX))?INDEX(GRID_MIN):Clamp(INDEX(floor(fMinX/GRID_CELLSIZE)), (INDEX)GRID_MIN, (INDEX)GRID_MAX);
|
iMinX = (Isinf(fMinX))?INDEX(GRID_MIN):Clamp(INDEX(floor(fMinX/GRID_CELLSIZE)), (INDEX)GRID_MIN, (INDEX)GRID_MAX);
|
||||||
iMinZ = (Isinf(fMinZ))?INDEX(GRID_MIN):Clamp(INDEX(floor(fMinZ/GRID_CELLSIZE)), (INDEX)GRID_MIN, (INDEX)GRID_MAX);
|
iMinZ = (Isinf(fMinZ))?INDEX(GRID_MIN):Clamp(INDEX(floor(fMinZ/GRID_CELLSIZE)), (INDEX)GRID_MIN, (INDEX)GRID_MAX);
|
||||||
|
|
|
@ -470,9 +470,15 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector)
|
||||||
// don't cast ray
|
// don't cast ray
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CEntity *l_cr_penOrigin = cr_penOrigin;
|
||||||
|
|
||||||
// for each polygon in the sector
|
// for each polygon in the sector
|
||||||
FOREACHINSTATICARRAY(pbscSector->bsc_abpoPolygons, CBrushPolygon, itpoPolygon) {
|
// FOREACHINSTATICARRAY(pbscSector->bsc_abpoPolygons, CBrushPolygon, itpoPolygon) {
|
||||||
CBrushPolygon &bpoPolygon = itpoPolygon.Current();
|
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) {
|
if (&bpoPolygon==cr_pbpoIgnore) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -480,7 +486,7 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector)
|
||||||
|
|
||||||
ULONG ulFlags = bpoPolygon.bpo_ulFlags;
|
ULONG ulFlags = bpoPolygon.bpo_ulFlags;
|
||||||
// if not testing recursively
|
// if not testing recursively
|
||||||
if (cr_penOrigin==NULL) {
|
if (l_cr_penOrigin==NULL) {
|
||||||
// if the polygon is portal
|
// if the polygon is portal
|
||||||
if (ulFlags&BPOF_PORTAL) {
|
if (ulFlags&BPOF_PORTAL) {
|
||||||
// if it is translucent or selected
|
// if it is translucent or selected
|
||||||
|
@ -506,13 +512,34 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef __ARM_NEON__
|
||||||
// get distances of ray points from the polygon plane
|
// 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 fDistance0 = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vOrigin);
|
||||||
FLOAT fDistance1 = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vTarget);
|
FLOAT fDistance1 = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vTarget);
|
||||||
|
|
||||||
// if the ray hits the polygon plane
|
// if the ray hits the polygon plane
|
||||||
if (fDistance0>=0 && fDistance0>=fDistance1) {
|
if (fDistance0>=0 && fDistance0>=fDistance1) {
|
||||||
// calculate fraction of line before intersection
|
// calculate fraction of line before intersection
|
||||||
|
#endif
|
||||||
FLOAT fFraction = fDistance0/((fDistance0-fDistance1) + 0.0000001f/*correction*/);
|
FLOAT fFraction = fDistance0/((fDistance0-fDistance1) + 0.0000001f/*correction*/);
|
||||||
// calculate intersection coordinate
|
// calculate intersection coordinate
|
||||||
FLOAT3D vHitPoint = cr_vOrigin+(cr_vTarget-cr_vOrigin)*fFraction;
|
FLOAT3D vHitPoint = cr_vOrigin+(cr_vTarget-cr_vOrigin)*fFraction;
|
||||||
|
|
|
@ -103,7 +103,7 @@ functions:
|
||||||
// 3rd person view
|
// 3rd person view
|
||||||
FLOAT fDistance = 1.0f;
|
FLOAT fDistance = 1.0f;
|
||||||
CPlacement3D pl = ((CPlayerEntity&) *m_penOwner).en_plViewpoint;
|
CPlacement3D pl = ((CPlayerEntity&) *m_penOwner).en_plViewpoint;
|
||||||
BOOL bFollowCrossHair;
|
BOOL bFollowCrossHair = TRUE;
|
||||||
|
|
||||||
if (m_iViewType == VT_3RDPERSONVIEW) {
|
if (m_iViewType == VT_3RDPERSONVIEW) {
|
||||||
// little above player eyes so it can be seen where he is firing
|
// little above player eyes so it can be seen where he is firing
|
||||||
|
|
|
@ -1903,6 +1903,7 @@ static void PrintStats( CDrawPort *pdpDrawPort)
|
||||||
// display nothing
|
// display nothing
|
||||||
_iCheckNow = 0;
|
_iCheckNow = 0;
|
||||||
_iCheckMax = 0;
|
_iCheckMax = 0;
|
||||||
|
STAT_Enable(FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1943,6 +1944,7 @@ static void PrintStats( CDrawPort *pdpDrawPort)
|
||||||
if( hud_iStats==2 && hud_iEnableStats)
|
if( hud_iStats==2 && hud_iEnableStats)
|
||||||
{ // display extensive statistics
|
{ // display extensive statistics
|
||||||
CTString strReport;
|
CTString strReport;
|
||||||
|
STAT_Enable(TRUE);
|
||||||
STAT_Report(strReport);
|
STAT_Report(strReport);
|
||||||
STAT_Reset();
|
STAT_Reset();
|
||||||
|
|
||||||
|
@ -1958,6 +1960,7 @@ static void PrintStats( CDrawPort *pdpDrawPort)
|
||||||
pdpDrawPort->PutText( strFPS, 0, 40, C_WHITE|CT_OPAQUE);
|
pdpDrawPort->PutText( strFPS, 0, 40, C_WHITE|CT_OPAQUE);
|
||||||
pdpDrawPort->PutText( strReport, 4, 65, C_GREEN|CT_OPAQUE);
|
pdpDrawPort->PutText( strReport, 4, 65, C_GREEN|CT_OPAQUE);
|
||||||
}
|
}
|
||||||
|
else STAT_Enable(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -477,6 +477,17 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine)
|
||||||
SDL_Init(SDL_INIT_JOYSTICK); // don't care if this fails.
|
SDL_Init(SDL_INIT_JOYSTICK); // don't care if this fails.
|
||||||
#endif
|
#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;
|
_hInstance = hInstance;
|
||||||
ShowSplashScreen(hInstance);
|
ShowSplashScreen(hInstance);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user