2016-08-17 20:05:23 +00:00
|
|
|
#include "boo/System.hpp"
|
2016-07-25 22:52:02 +00:00
|
|
|
#include "GameGlobalObjects.hpp"
|
2016-07-21 05:21:45 +00:00
|
|
|
#include "CBooRenderer.hpp"
|
2016-07-25 22:52:02 +00:00
|
|
|
#include "CModel.hpp"
|
|
|
|
#include "Particle/CParticleGen.hpp"
|
2017-01-22 21:29:19 +00:00
|
|
|
#include "Particle/CGenDescription.hpp"
|
2017-01-22 17:36:25 +00:00
|
|
|
#include "Particle/CDecal.hpp"
|
|
|
|
#include "Particle/CElementGen.hpp"
|
2016-07-26 22:05:59 +00:00
|
|
|
#include "CMetroidModelInstance.hpp"
|
2016-08-05 20:26:23 +00:00
|
|
|
#include "Collision/CAreaOctTree.hpp"
|
2017-03-10 03:40:24 +00:00
|
|
|
#include "zeus/CUnitVector.hpp"
|
|
|
|
#include "Graphics/CSkinnedModel.hpp"
|
2017-03-14 07:03:58 +00:00
|
|
|
#include "zeus/CVector3d.hpp"
|
2016-07-25 22:52:02 +00:00
|
|
|
|
|
|
|
#define FOGVOL_RAMP_RES 256
|
2017-03-10 03:40:24 +00:00
|
|
|
#define FOGVOL_FAR 750.0
|
|
|
|
#define FOGVOL_NEAR 0.2
|
2016-07-25 22:52:02 +00:00
|
|
|
#define SPHERE_RAMP_RES 32
|
2016-07-21 05:21:45 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
static logvisor::Module Log("CBooRenderer");
|
|
|
|
|
|
|
|
static rstl::reserved_vector<CDrawable, 512> sDataHolder;
|
2016-07-25 22:52:02 +00:00
|
|
|
static rstl::reserved_vector<rstl::reserved_vector<CDrawable*, 128>, 50> sBucketsHolder;
|
|
|
|
static rstl::reserved_vector<CDrawablePlaneObject, 8> sPlaneObjectDataHolder;
|
|
|
|
static rstl::reserved_vector<u16, 8> sPlaneObjectBucketHolder;
|
|
|
|
|
|
|
|
rstl::reserved_vector<u16, 50> Buckets::sBucketIndex;
|
2017-11-12 05:14:57 +00:00
|
|
|
rstl::reserved_vector<CDrawable, 512>* Buckets::sData = nullptr;
|
2016-07-25 22:52:02 +00:00
|
|
|
rstl::reserved_vector<rstl::reserved_vector<CDrawable*, 128>, 50>* Buckets::sBuckets = nullptr;
|
|
|
|
rstl::reserved_vector<CDrawablePlaneObject, 8>* Buckets::sPlaneObjectData = nullptr;
|
|
|
|
rstl::reserved_vector<u16, 8>* Buckets::sPlaneObjectBucket = nullptr;
|
|
|
|
const float Buckets::skWorstMinMaxDistance[2] = {99999.f, -99999.f};
|
|
|
|
float Buckets::sMinMaxDistance[2];
|
|
|
|
|
|
|
|
void Buckets::Clear()
|
|
|
|
{
|
|
|
|
sData->clear();
|
2016-07-26 02:43:55 +00:00
|
|
|
sBucketIndex.clear();
|
2016-07-25 22:52:02 +00:00
|
|
|
sPlaneObjectData->clear();
|
|
|
|
sPlaneObjectBucket->clear();
|
|
|
|
for (rstl::reserved_vector<CDrawable*, 128>& bucket : *sBuckets)
|
|
|
|
bucket.clear();
|
|
|
|
sMinMaxDistance[0] = skWorstMinMaxDistance[0];
|
|
|
|
sMinMaxDistance[1] = skWorstMinMaxDistance[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Buckets::Sort()
|
|
|
|
{
|
2016-07-26 02:43:55 +00:00
|
|
|
float delta = std::max(1.f, sMinMaxDistance[1] - sMinMaxDistance[0]);
|
2017-11-12 05:14:57 +00:00
|
|
|
float pitch = 49.f / delta;
|
|
|
|
for (auto it = sPlaneObjectData->begin() ; it != sPlaneObjectData->end() ; ++it)
|
|
|
|
if (sPlaneObjectBucket->size() < 8)
|
|
|
|
sPlaneObjectBucket->push_back(s16(it - sPlaneObjectData->begin()));
|
2016-07-26 02:43:55 +00:00
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
u32 precision = 50;
|
|
|
|
if (sPlaneObjectBucket->size())
|
2016-07-26 02:43:55 +00:00
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
std::sort(sPlaneObjectBucket->begin(), sPlaneObjectBucket->end(),
|
|
|
|
[](u16 a, u16 b) -> bool
|
|
|
|
{
|
|
|
|
return (*sPlaneObjectData)[a].GetDistance() >= (*sPlaneObjectData)[b].GetDistance();
|
|
|
|
});
|
|
|
|
precision = 50 / u32(sPlaneObjectBucket->size() + 1);
|
|
|
|
pitch = 1.f / (delta / float(precision - 2));
|
2016-07-26 02:43:55 +00:00
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
int accum = 0;
|
|
|
|
for (u16 idx : *sPlaneObjectBucket)
|
|
|
|
{
|
|
|
|
++accum;
|
|
|
|
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
|
|
|
planeObj.x24_targetBucket = u16(precision * accum);
|
|
|
|
}
|
2016-07-26 02:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (CDrawable& drawable : *sData)
|
|
|
|
{
|
|
|
|
int slot;
|
2017-11-12 05:14:57 +00:00
|
|
|
float relDist = drawable.GetDistance() - sMinMaxDistance[0];
|
2016-07-26 02:43:55 +00:00
|
|
|
if (sPlaneObjectBucket->empty())
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
slot = zeus::clamp(1, int(relDist * pitch), 49);
|
2016-07-26 02:43:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
slot = zeus::clamp(0, int(relDist * pitch), int(precision) - 2);
|
|
|
|
for (u16 idx : *sPlaneObjectBucket)
|
|
|
|
{
|
|
|
|
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
|
|
|
bool partial, full;
|
|
|
|
if (planeObj.x3c_25_zOnly)
|
|
|
|
{
|
|
|
|
partial = drawable.GetBounds().max.z > planeObj.GetPlane().d;
|
|
|
|
full = drawable.GetBounds().min.z > planeObj.GetPlane().d;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
partial = planeObj.GetPlane().pointToPlaneDist(
|
|
|
|
drawable.GetBounds().closestPointAlongVector(planeObj.GetPlane().vec)) > 0.f;
|
|
|
|
full = planeObj.GetPlane().pointToPlaneDist(
|
|
|
|
drawable.GetBounds().furthestPointAlongVector(planeObj.GetPlane().vec)) > 0.f;
|
|
|
|
}
|
|
|
|
bool cont;
|
|
|
|
if (drawable.GetType() == EDrawableType::Particle)
|
|
|
|
cont = planeObj.x3c_24_invertTest ? !partial : full;
|
|
|
|
else
|
|
|
|
cont = planeObj.x3c_24_invertTest ? (!partial || !full) : (partial || full);
|
|
|
|
if (!cont)
|
|
|
|
break;
|
|
|
|
}
|
2016-07-26 02:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (slot == -1)
|
|
|
|
slot = 49;
|
2017-11-12 05:14:57 +00:00
|
|
|
rstl::reserved_vector<CDrawable*, 128>& bucket = (*sBuckets)[slot];
|
|
|
|
if (bucket.size() < bucket.capacity())
|
|
|
|
bucket.push_back(&drawable);
|
2016-07-26 02:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int bucketIdx = sBuckets->size();
|
|
|
|
for (auto it = sBuckets->rbegin() ; it != sBuckets->rend() ; ++it)
|
|
|
|
{
|
|
|
|
--bucketIdx;
|
|
|
|
rstl::reserved_vector<CDrawable*, 128>& bucket = *it;
|
|
|
|
if (bucket.size())
|
|
|
|
{
|
2016-08-03 21:53:03 +00:00
|
|
|
sBucketIndex.push_back(bucketIdx);
|
2016-07-26 02:43:55 +00:00
|
|
|
std::sort(bucket.begin(), bucket.end(),
|
|
|
|
[](CDrawable* a, CDrawable* b) -> bool
|
|
|
|
{
|
2017-11-21 10:36:18 +00:00
|
|
|
return a->GetDistance() > b->GetDistance();
|
2016-07-26 02:43:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto it = sPlaneObjectBucket->rbegin() ; it != sPlaneObjectBucket->rend() ; ++it)
|
|
|
|
{
|
|
|
|
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[*it];
|
|
|
|
rstl::reserved_vector<CDrawable*, 128>& bucket = (*sBuckets)[planeObj.x24_targetBucket];
|
|
|
|
bucket.push_back(&planeObj);
|
|
|
|
}
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
void Buckets::InsertPlaneObject(float dist, float something, const zeus::CAABox& aabb, bool invertTest,
|
|
|
|
const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, const void* data)
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
sPlaneObjectData->push_back(CDrawablePlaneObject(dtype, dist, something, aabb, invertTest, plane, zOnly, data));
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Buckets::Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype,
|
|
|
|
const void* data, const zeus::CPlane& plane, u16 extraSort)
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
if (sData->size() != sData->capacity())
|
|
|
|
{
|
|
|
|
float dist = plane.pointToPlaneDist(pos);
|
|
|
|
sData->push_back(CDrawable(dtype, extraSort, dist, aabb, data));
|
|
|
|
if (sMinMaxDistance[0] > dist)
|
|
|
|
sMinMaxDistance[0] = dist;
|
|
|
|
if (sMinMaxDistance[1] < dist)
|
|
|
|
sMinMaxDistance[1] = dist;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log.report(logvisor::Fatal, "Rendering buckets filled to capacity");
|
|
|
|
}
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Buckets::Shutdown()
|
|
|
|
{
|
|
|
|
sData = nullptr;
|
|
|
|
sBuckets = nullptr;
|
|
|
|
sPlaneObjectData = nullptr;
|
|
|
|
sPlaneObjectBucket = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Buckets::Init()
|
|
|
|
{
|
|
|
|
sData = &sDataHolder;
|
|
|
|
sBuckets = &sBucketsHolder;
|
|
|
|
sBuckets->resize(50);
|
|
|
|
sPlaneObjectData = &sPlaneObjectDataHolder;
|
|
|
|
sPlaneObjectBucket = &sPlaneObjectBucketHolder;
|
|
|
|
sMinMaxDistance[0] = skWorstMinMaxDistance[0];
|
|
|
|
sMinMaxDistance[1] = skWorstMinMaxDistance[1];
|
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
CBooRenderer::CAreaListItem::CAreaListItem
|
2017-03-03 07:18:12 +00:00
|
|
|
(const std::vector<CMetroidModelInstance>* geom,
|
|
|
|
const CAreaRenderOctTree* octTree,
|
|
|
|
std::vector<TCachedToken<CTexture>>&& textures,
|
2017-11-19 23:48:09 +00:00
|
|
|
std::vector<CBooModel*>&& models, int areaIdx,
|
|
|
|
const SShader* shaderSet)
|
2017-03-03 07:18:12 +00:00
|
|
|
: x0_geometry(geom), x4_octTree(octTree), x8_textures(std::move(textures)),
|
2017-11-19 23:48:09 +00:00
|
|
|
x10_models(std::move(models)), x18_areaIdx(areaIdx), m_shaderSet(shaderSet) {}
|
2016-07-26 22:05:59 +00:00
|
|
|
|
|
|
|
CBooRenderer::CAreaListItem::~CAreaListItem() {}
|
|
|
|
|
2017-03-07 05:36:02 +00:00
|
|
|
static inline bool TestBit(const u32* words, int bit)
|
|
|
|
{
|
|
|
|
return (words[bit / 32] & (1 << (bit & 0x1f))) != 0;
|
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::ActivateLightsForModel(CAreaListItem* item, CBooModel& model)
|
|
|
|
{
|
|
|
|
std::vector<CLight> thisLights;
|
|
|
|
thisLights.reserve(4);
|
|
|
|
|
2017-03-03 07:18:12 +00:00
|
|
|
if (x300_dynamicLights.size())
|
2016-07-28 04:55:06 +00:00
|
|
|
{
|
2017-03-07 05:36:02 +00:00
|
|
|
u32 lightOctreeWordCount = 0;
|
|
|
|
u32* lightOctreeWords = nullptr;
|
|
|
|
if (item && model.x44_areaInstanceIdx != -1)
|
2016-07-28 04:55:06 +00:00
|
|
|
{
|
2017-03-07 05:36:02 +00:00
|
|
|
lightOctreeWordCount = item->x4_octTree->x14_bitmapWordCount;
|
|
|
|
lightOctreeWords = item->x1c_lightOctreeWords.data();
|
2016-07-28 04:55:06 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 05:36:02 +00:00
|
|
|
float lightRads[4] = {-1.f, -1.f, -1.f, -1.f};
|
|
|
|
CLight* lightRefs[4] = {};
|
|
|
|
auto it = x300_dynamicLights.begin();
|
|
|
|
for (int i=0 ; i<4 && it != x300_dynamicLights.end() ; ++it, lightOctreeWords += lightOctreeWordCount)
|
2016-07-28 04:55:06 +00:00
|
|
|
{
|
2017-03-07 05:36:02 +00:00
|
|
|
CLight& refLight = *it;
|
|
|
|
if (lightOctreeWords && !TestBit(lightOctreeWords, model.x44_areaInstanceIdx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bool foundLight = false;
|
|
|
|
for (int j=0 ; j<i ; ++j)
|
2016-07-28 04:55:06 +00:00
|
|
|
{
|
2017-03-07 05:36:02 +00:00
|
|
|
if (lightRefs[j] == &refLight)
|
2016-07-28 04:55:06 +00:00
|
|
|
continue;
|
2017-03-07 05:36:02 +00:00
|
|
|
float radius = model.x20_aabb.intersectionRadius(
|
|
|
|
zeus::CSphere(refLight.GetPosition(), refLight.GetRadius()));
|
|
|
|
if (radius < 0.f)
|
|
|
|
break;
|
|
|
|
if (lightRads[j] <= radius)
|
|
|
|
break;
|
|
|
|
lightRads[j] = radius;
|
|
|
|
lightRefs[j] = &refLight;
|
|
|
|
thisLights.push_back(refLight);
|
|
|
|
foundLight = true;
|
2016-07-28 04:55:06 +00:00
|
|
|
}
|
2017-03-07 05:36:02 +00:00
|
|
|
|
|
|
|
if (foundLight)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
float radius = model.x20_aabb.intersectionRadius(
|
|
|
|
zeus::CSphere(refLight.GetPosition(), refLight.GetRadius()));
|
|
|
|
if (radius < 0.f)
|
|
|
|
continue;
|
|
|
|
lightRads[i] = radius;
|
|
|
|
lightRefs[i] = &refLight;
|
|
|
|
thisLights.push_back(refLight);
|
|
|
|
++i;
|
2016-07-28 04:55:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-07 05:36:02 +00:00
|
|
|
model.ActivateLights(thisLights);
|
2016-07-28 04:55:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::RenderBucketItems(CAreaListItem* item)
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
2016-08-03 21:53:03 +00:00
|
|
|
CModelFlags flags;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
2016-08-03 21:53:03 +00:00
|
|
|
|
2016-07-25 22:52:02 +00:00
|
|
|
for (u16 idx : Buckets::sBucketIndex)
|
|
|
|
{
|
|
|
|
rstl::reserved_vector<CDrawable*, 128>& bucket = (*Buckets::sBuckets)[idx];
|
|
|
|
for (CDrawable* drawable : bucket)
|
|
|
|
{
|
|
|
|
switch (drawable->GetType())
|
|
|
|
{
|
|
|
|
case EDrawableType::Particle:
|
|
|
|
{
|
|
|
|
static_cast<CParticleGen*>((void*)drawable->GetData())->Render();
|
|
|
|
break;
|
|
|
|
}
|
2016-08-03 21:53:03 +00:00
|
|
|
case EDrawableType::WorldSurface:
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
//SetupRendererStates();
|
2016-07-25 22:52:02 +00:00
|
|
|
CBooSurface* surf = static_cast<CBooSurface*>((void*)drawable->GetData());
|
|
|
|
CBooModel* model = surf->m_parent;
|
|
|
|
if (model)
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
//ActivateLightsForModel(item, *model);
|
2016-08-03 21:53:03 +00:00
|
|
|
model->DrawSurface(*surf, flags);
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
if (xa8_drawableCallback)
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
xa8_drawableCallback(drawable->GetData(), xac_callbackContext,
|
2017-03-04 04:31:08 +00:00
|
|
|
int(drawable->GetType()) - 2);
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::HandleUnsortedModel(CAreaListItem* item, CBooModel& model)
|
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
//ActivateLightsForModel(item, model);
|
2016-07-28 04:55:06 +00:00
|
|
|
CBooSurface* surf = model.x38_firstUnsortedSurface;
|
2016-08-03 21:53:03 +00:00
|
|
|
CModelFlags flags;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
2016-07-28 04:55:06 +00:00
|
|
|
while (surf)
|
|
|
|
{
|
2016-08-03 21:53:03 +00:00
|
|
|
model.DrawSurface(*surf, flags);
|
2016-07-28 04:55:06 +00:00
|
|
|
surf = surf->m_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
static const struct FogVolumeControl
|
|
|
|
{
|
|
|
|
|
|
|
|
u32 xfc_[12][2] =
|
|
|
|
{
|
|
|
|
{0, 1},
|
|
|
|
{1, 3},
|
|
|
|
{3, 2},
|
|
|
|
{2, 0},
|
|
|
|
{4, 5},
|
|
|
|
{5, 7},
|
|
|
|
{7, 6},
|
|
|
|
{6, 4},
|
|
|
|
{0, 4},
|
|
|
|
{1, 5},
|
|
|
|
{3, 7},
|
|
|
|
{2, 6}
|
|
|
|
};
|
|
|
|
u32 x15c_[8] = {};
|
|
|
|
//GXVtxDescList x17c_; {{POS, DIRECT}, {TEX0, DIRECT}}
|
|
|
|
|
|
|
|
} s_FogVolumeCtrl = {};
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
static const int OrthogonalAxis[3][2] =
|
|
|
|
{
|
|
|
|
{1, 2},
|
|
|
|
{0, 2},
|
|
|
|
{0, 1}
|
|
|
|
};
|
|
|
|
|
|
|
|
static float GetPlaneInterpolant(const zeus::CPlane& plane,
|
|
|
|
const zeus::CVector3f& vert1,
|
|
|
|
const zeus::CVector3f& vert2)
|
|
|
|
{
|
|
|
|
return zeus::clamp(0.f, -plane.pointToPlaneDist(vert1) / (vert2 - vert1).dot(plane.normal()), 1.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::CalcDrawFogFan(const zeus::CPlane* planes, int numPlanes, const zeus::CVector3f* verts,
|
|
|
|
int numVerts, int iteration, int level, CFogVolumePlaneShader& fogVol)
|
|
|
|
{
|
|
|
|
if (level == iteration)
|
|
|
|
{
|
|
|
|
CalcDrawFogFan(planes, numPlanes, verts, numVerts, iteration, level + 1, fogVol);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level == numPlanes)
|
|
|
|
{
|
|
|
|
fogVol.addFan(verts, numVerts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const zeus::CPlane& plane = planes[level];
|
|
|
|
u32 insidePlaneCount = 0;
|
|
|
|
bool outsidePlane[4];
|
|
|
|
for (int i=0 ; i<numVerts ; ++i)
|
|
|
|
outsidePlane[insidePlaneCount++] = plane.normal().dot(verts[i]) < plane.d;
|
|
|
|
|
|
|
|
u32 numUseVerts = 0;
|
|
|
|
zeus::CVector3f useVerts[4];
|
|
|
|
for (int i=0 ; i<numVerts ; ++i)
|
|
|
|
{
|
|
|
|
int nextIdx = (i + 1) % numVerts;
|
2017-03-17 23:33:02 +00:00
|
|
|
int insidePair = int(outsidePlane[i]) | (int(outsidePlane[nextIdx]) << 1);
|
2017-03-14 07:03:58 +00:00
|
|
|
if (!(insidePair & 0x1))
|
|
|
|
useVerts[numUseVerts++] = verts[i];
|
|
|
|
if (insidePair == 1 || insidePair == 2)
|
|
|
|
{
|
|
|
|
/* Inside/outside transition; clip verts to other plane boundary */
|
|
|
|
const zeus::CVector3f vert1 = verts[i];
|
|
|
|
const zeus::CVector3f vert2 = verts[nextIdx];
|
|
|
|
float interp = GetPlaneInterpolant(plane, vert1, vert2);
|
|
|
|
if (interp > 0.f || interp < 1.f)
|
|
|
|
useVerts[numUseVerts++] = (vert1 * (1.f - interp)) + (vert2 * interp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numUseVerts >= 3)
|
|
|
|
CalcDrawFogFan(planes, numPlanes, useVerts, numUseVerts, iteration, level + 1, fogVol);
|
|
|
|
}
|
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
void CBooRenderer::DrawFogSlices(const zeus::CPlane* planes, int numPlanes,
|
2017-03-14 07:03:58 +00:00
|
|
|
int iteration, const zeus::CVector3f& center, float longestAxis,
|
|
|
|
CFogVolumePlaneShader& fogVol)
|
2017-03-10 03:40:24 +00:00
|
|
|
{
|
2017-03-14 07:03:58 +00:00
|
|
|
u32 vertCount = 0;
|
|
|
|
zeus::CVector3d verts[4];
|
|
|
|
u32 vert2Count = 0;
|
|
|
|
zeus::CVector3f verts2[4];
|
|
|
|
const zeus::CPlane& plane = planes[iteration];
|
|
|
|
int longestNormAxis = std::fabs(plane[1]) > std::fabs(plane[0]);
|
|
|
|
if (std::fabs(plane[2]) > std::fabs(plane[longestNormAxis]))
|
|
|
|
longestNormAxis = 2;
|
|
|
|
|
|
|
|
zeus::CVector3d pointOnPlane = center - (plane.pointToPlaneDist(center) * plane.normal());
|
|
|
|
|
|
|
|
float deltaSign = plane[longestNormAxis] >= 0.f ? -1.f : 1.f;
|
|
|
|
if (longestNormAxis == 1)
|
|
|
|
deltaSign = -deltaSign;
|
|
|
|
|
|
|
|
zeus::CVector3d vec1;
|
|
|
|
zeus::CVector3d vec2;
|
2017-03-10 03:40:24 +00:00
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
vec1[OrthogonalAxis[longestNormAxis][0]] = longestAxis;
|
|
|
|
vec2[OrthogonalAxis[longestNormAxis][1]] = deltaSign * longestAxis;
|
|
|
|
|
|
|
|
verts[vertCount++] = pointOnPlane - vec1 - vec2;
|
|
|
|
verts[vertCount++] = pointOnPlane + vec1 - vec2;
|
|
|
|
verts[vertCount++] = pointOnPlane + vec1 + vec2;
|
|
|
|
verts[vertCount++] = pointOnPlane - vec1 + vec2;
|
|
|
|
|
|
|
|
zeus::CVector3d planeNormal = plane.normal();
|
|
|
|
for (const zeus::CVector3d& vert : verts)
|
2017-12-18 02:54:50 +00:00
|
|
|
verts2[vert2Count++] = vert - (planeNormal * zeus::CVector3f(planeNormal.dot(vert) - plane.d));
|
2017-03-14 07:03:58 +00:00
|
|
|
|
|
|
|
CalcDrawFogFan(planes, numPlanes, verts2, vert2Count, iteration, 0, fogVol);
|
2017-03-10 03:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model,
|
|
|
|
const zeus::CTransform& modelMtx, const zeus::CTransform& viewMtx,
|
2017-03-14 07:03:58 +00:00
|
|
|
const CSkinnedModel* sModel, int pass, CFogVolumePlaneShader* fvs)
|
2017-03-10 03:40:24 +00:00
|
|
|
{
|
|
|
|
if (!model && !sModel)
|
|
|
|
{
|
2017-03-14 07:03:58 +00:00
|
|
|
if (pass == 0)
|
|
|
|
{
|
|
|
|
zeus::CAABox xfAABB = aabb.getTransformedAABox(modelMtx);
|
|
|
|
zeus::CUnitVector3f viewNormal(viewMtx.basis[1]);
|
|
|
|
zeus::CPlane planes[7] =
|
|
|
|
{
|
|
|
|
{zeus::CVector3f::skRight, xfAABB.min.x},
|
|
|
|
{zeus::CVector3f::skLeft, -xfAABB.max.x},
|
|
|
|
{zeus::CVector3f::skForward, xfAABB.min.y},
|
|
|
|
{zeus::CVector3f::skBack, -xfAABB.max.y},
|
|
|
|
{zeus::CVector3f::skUp, xfAABB.min.z},
|
|
|
|
{zeus::CVector3f::skDown, -xfAABB.max.z},
|
|
|
|
{viewNormal, viewNormal.dot(viewMtx.origin) + 0.2f + 0.1f}
|
|
|
|
};
|
|
|
|
|
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
|
|
|
|
|
|
|
float longestAxis = std::max(std::max(
|
|
|
|
xfAABB.max.x - xfAABB.min.x,
|
|
|
|
xfAABB.max.y - xfAABB.min.y),
|
|
|
|
xfAABB.max.z - xfAABB.min.z) * 2.f;
|
|
|
|
|
|
|
|
fvs->reset(7 * 6);
|
|
|
|
for (int i=0 ; i<7 ; ++i)
|
|
|
|
DrawFogSlices(planes, 7, i, xfAABB.center(), longestAxis, *fvs);
|
|
|
|
fvs->draw(0);
|
|
|
|
}
|
|
|
|
else
|
2017-03-10 03:40:24 +00:00
|
|
|
{
|
2017-03-14 07:03:58 +00:00
|
|
|
fvs->draw(pass);
|
|
|
|
}
|
2017-03-10 03:40:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CModelFlags flags;
|
2017-03-14 07:03:58 +00:00
|
|
|
switch (pass)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullLEqualAlphaOnly;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color = zeus::CColor(1.f, 1.f, 1.f, 1.f);
|
2017-03-14 07:03:58 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColorFrontfaceCullAlwaysAlphaOnly;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color = zeus::CColor(1.f, 1.f, 1.f, 1.f);
|
2017-03-14 07:03:58 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color = zeus::CColor(1.f, 1.f, 1.f, 0.f);
|
2017-03-14 07:03:58 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullGreaterAlphaOnly;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color = zeus::CColor(1.f, 1.f, 1.f, 0.f);
|
2017-03-14 07:03:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
if (sModel)
|
|
|
|
{
|
|
|
|
sModel->Draw(flags);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
model->UpdateLastFrame();
|
2017-03-14 07:03:58 +00:00
|
|
|
model->Draw(flags);
|
2017-03-10 03:40:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:28:31 +00:00
|
|
|
void CBooRenderer::SetupRendererStates() const
|
|
|
|
{
|
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
|
|
|
CGraphics::g_ColorRegs[1] = x2fc_tevReg1Color;
|
|
|
|
}
|
|
|
|
|
2017-03-07 05:36:02 +00:00
|
|
|
void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
|
|
|
|
const CModel* model, const CSkinnedModel* sModel)
|
|
|
|
{
|
|
|
|
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(false);
|
2017-03-10 03:40:24 +00:00
|
|
|
zeus::CVector4f points[8];
|
2017-03-07 05:36:02 +00:00
|
|
|
|
|
|
|
for (int i=0 ; i<8 ; ++i)
|
|
|
|
{
|
2017-03-14 07:03:58 +00:00
|
|
|
zeus::CVector3f xfPt = CGraphics::g_GXModelView * aabb.getPoint(i);
|
2017-03-10 03:40:24 +00:00
|
|
|
points[i] = proj * zeus::CVector4f(xfPt);
|
2017-03-07 05:36:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
zeus::CVector2i vpMax(0, 0);
|
|
|
|
zeus::CVector2i vpMin(g_Viewport.x8_width, g_Viewport.xc_height);
|
2017-03-07 05:36:02 +00:00
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
bool b1 = true;
|
2017-03-07 05:36:02 +00:00
|
|
|
for (int i=0 ; i<20 ; ++i)
|
|
|
|
{
|
|
|
|
zeus::CVector3f overW;
|
|
|
|
if (i < 8)
|
|
|
|
{
|
2017-03-10 03:40:24 +00:00
|
|
|
overW = points[i].toVec3f() * (1.f / points[i].w);
|
2017-03-07 05:36:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-10 03:40:24 +00:00
|
|
|
const zeus::CVector4f& pt1 = points[s_FogVolumeCtrl.xfc_[i-8][0]];
|
|
|
|
const zeus::CVector4f& pt2 = points[s_FogVolumeCtrl.xfc_[i-8][1]];
|
|
|
|
|
|
|
|
bool eq1 = (pt1.z / pt1.w) == 1.f;
|
|
|
|
bool eq2 = (pt2.z / pt2.w) == 1.f;
|
|
|
|
if (eq1 == eq2)
|
|
|
|
continue;
|
2017-03-07 05:36:02 +00:00
|
|
|
|
2017-03-10 03:40:24 +00:00
|
|
|
float interp = -(pt1.w - 1.f) / (pt2.w - pt1.w);
|
|
|
|
if (interp <= 0.f || interp >= 1.f)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
float wRecip = 1.f / (interp * (pt2.w - pt1.w) + pt1.w);
|
|
|
|
zeus::CVector3f pt1_3 = pt1.toVec3f();
|
|
|
|
zeus::CVector3f pt2_3 = pt2.toVec3f();
|
|
|
|
overW = (pt1_3 + interp * (pt2_3 - pt1_3)) * wRecip;
|
2017-03-07 05:36:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
//if (overW.z > 1.001f)
|
|
|
|
// continue;
|
2017-03-10 03:40:24 +00:00
|
|
|
|
|
|
|
int vpX = zeus::clamp(0, int(g_Viewport.x8_width * overW.x * 0.5f + (g_Viewport.x8_width / 2)), int(g_Viewport.x8_width));
|
|
|
|
int vpY = zeus::clamp(0, int(g_Viewport.xc_height * overW.y * 0.5f + (g_Viewport.xc_height / 2)), int(g_Viewport.xc_height));
|
|
|
|
vpMax.x = std::max(vpMax.x, vpX);
|
|
|
|
vpMin.x = std::min(vpMin.x, vpX);
|
|
|
|
vpMax.y = std::max(vpMax.y, vpY);
|
|
|
|
vpMin.y = std::min(vpMin.y, vpY);
|
|
|
|
b1 = false;
|
|
|
|
}
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
zeus::CVector2i vpSize = {vpMax.x - vpMin.x, vpMax.y - vpMin.y};
|
2017-03-10 03:40:24 +00:00
|
|
|
if (vpSize.x <= 0 || vpSize.y <= 0)
|
|
|
|
return;
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
SClipScreenRect rect = {};
|
|
|
|
rect.x4_left = vpMin.x;
|
|
|
|
rect.x8_top = vpMin.y;
|
|
|
|
rect.xc_width = vpSize.x;
|
|
|
|
rect.x10_height = vpSize.y;
|
|
|
|
|
|
|
|
rect.x4_left = 0;
|
|
|
|
rect.x8_top = 0;
|
|
|
|
rect.xc_width = g_Viewport.x8_width;
|
|
|
|
rect.x10_height = g_Viewport.xc_height;
|
|
|
|
|
|
|
|
//CGraphics::SetScissor(vpMin.x, vpMin.y, vpSize.x, vpSize.y);
|
|
|
|
|
|
|
|
CFogVolumePlaneShader* fvs;
|
|
|
|
if (!model && !sModel)
|
2017-03-10 03:40:24 +00:00
|
|
|
{
|
2017-03-14 07:03:58 +00:00
|
|
|
fvs = &*((m_nextFogVolumePlaneShader == m_fogVolumePlaneShaders.end()) ?
|
|
|
|
m_fogVolumePlaneShaders.insert(m_fogVolumePlaneShaders.end(), CFogVolumePlaneShader()) :
|
|
|
|
m_nextFogVolumePlaneShader++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fvs = nullptr;
|
2017-03-10 03:40:24 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs);
|
|
|
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs);
|
|
|
|
|
|
|
|
CGraphics::ResolveSpareDepth(rect, 0);
|
2017-03-10 03:40:24 +00:00
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs);
|
|
|
|
RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs);
|
2017-03-10 03:40:24 +00:00
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
CGraphics::ResolveSpareDepth(rect, 1);
|
2017-03-10 03:40:24 +00:00
|
|
|
|
2017-03-14 07:03:58 +00:00
|
|
|
auto fvf = (m_nextFogVolumeFilter == m_fogVolumeFilters.end()) ?
|
|
|
|
m_fogVolumeFilters.insert(m_fogVolumeFilters.end(), CFogVolumeFilter()) :
|
|
|
|
m_nextFogVolumeFilter++;
|
|
|
|
fvf->draw2WayPass(color);
|
|
|
|
fvf->draw1WayPass(color);
|
|
|
|
|
|
|
|
//CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height);
|
2017-03-07 05:36:02 +00:00
|
|
|
}
|
|
|
|
|
2016-07-25 22:52:02 +00:00
|
|
|
void CBooRenderer::GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx)
|
|
|
|
{
|
|
|
|
u8 data[FOGVOL_RAMP_RES][FOGVOL_RAMP_RES] = {};
|
|
|
|
for (int y=0 ; y<FOGVOL_RAMP_RES ; ++y)
|
|
|
|
{
|
|
|
|
for (int x=0 ; x<FOGVOL_RAMP_RES ; ++x)
|
|
|
|
{
|
|
|
|
int tmp = y << 16 | x << 8 | 0x7f;
|
2017-03-10 03:40:24 +00:00
|
|
|
double a = zeus::clamp(0.0, (-150.0 / (tmp / double(0xffffff) *
|
|
|
|
(FOGVOL_FAR - FOGVOL_NEAR) - FOGVOL_FAR) - FOGVOL_NEAR) * 3.0 /
|
|
|
|
(FOGVOL_FAR - FOGVOL_NEAR), 1.0);
|
2016-07-25 22:52:02 +00:00
|
|
|
data[y][x] = (a * a + a) / 2.f * 255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x1b8_fogVolumeRamp = ctx.newStaticTexture(FOGVOL_RAMP_RES, FOGVOL_RAMP_RES, 1,
|
2017-10-01 04:26:46 +00:00
|
|
|
boo::TextureFormat::I8, boo::TextureClampMode::Repeat, data[0],
|
2016-07-25 22:52:02 +00:00
|
|
|
FOGVOL_RAMP_RES * FOGVOL_RAMP_RES);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::GenerateSphereRampTex(boo::IGraphicsDataFactory::Context& ctx)
|
|
|
|
{
|
|
|
|
u8 data[SPHERE_RAMP_RES][SPHERE_RAMP_RES] = {};
|
|
|
|
float halfRes = SPHERE_RAMP_RES / 2.f;
|
|
|
|
for (int y=0 ; y<SPHERE_RAMP_RES ; ++y)
|
|
|
|
{
|
|
|
|
for (int x=0 ; x<SPHERE_RAMP_RES ; ++x)
|
|
|
|
{
|
|
|
|
zeus::CVector2f vec((x - halfRes) / halfRes, (y - halfRes) / halfRes);
|
2016-07-31 05:06:05 +00:00
|
|
|
data[y][x] = 255 - zeus::clamp(0.f, vec.canBeNormalized() ? vec.magnitude() : 0.f, 1.f) * 255;
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
x220_sphereRamp = ctx.newStaticTexture(SPHERE_RAMP_RES, SPHERE_RAMP_RES, 1,
|
2017-10-01 04:26:46 +00:00
|
|
|
boo::TextureFormat::I8, boo::TextureClampMode::Repeat, data[0],
|
2016-07-25 22:52:02 +00:00
|
|
|
SPHERE_RAMP_RES * SPHERE_RAMP_RES);
|
|
|
|
}
|
|
|
|
|
2017-06-01 19:10:06 +00:00
|
|
|
void CBooRenderer::GenerateScanLinesVBO(boo::IGraphicsDataFactory::Context& ctx)
|
|
|
|
{
|
|
|
|
std::vector<zeus::CVector3f> verts;
|
|
|
|
verts.reserve(670);
|
|
|
|
|
|
|
|
for (int i=0 ; i<112 ; ++i)
|
|
|
|
{
|
2017-11-16 23:49:25 +00:00
|
|
|
verts.push_back(zeus::CVector3f(-1.f, (i * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
2017-06-01 19:10:06 +00:00
|
|
|
if (i != 0)
|
|
|
|
verts.push_back(verts.back());
|
2017-11-16 23:49:25 +00:00
|
|
|
verts.push_back(zeus::CVector3f(-1.f, (i * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
|
|
|
verts.push_back(zeus::CVector3f( 1.f, (i * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
|
|
|
verts.push_back(zeus::CVector3f( 1.f, (i * (4.f / 448.f) - (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
2017-06-01 19:10:06 +00:00
|
|
|
if (i != 111)
|
|
|
|
verts.push_back(verts.back());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_scanLinesEvenVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(),
|
|
|
|
sizeof(zeus::CVector3f), verts.size());
|
|
|
|
|
|
|
|
verts.clear();
|
|
|
|
|
|
|
|
for (int i=0 ; i<112 ; ++i)
|
|
|
|
{
|
2017-11-16 23:49:25 +00:00
|
|
|
verts.push_back(zeus::CVector3f(-1.f, (i * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f));
|
2017-06-01 19:10:06 +00:00
|
|
|
if (i != 0)
|
|
|
|
verts.push_back(verts.back());
|
2017-11-16 23:49:25 +00:00
|
|
|
verts.push_back(zeus::CVector3f(-1.f, (i * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
|
|
|
verts.push_back(zeus::CVector3f( 1.f, (i * (4.f / 448.f) + (3.f / 448.f)) * 2.f - 1.f, 0.f));
|
|
|
|
verts.push_back(zeus::CVector3f( 1.f, (i * (4.f / 448.f) + (1.f / 448.f)) * 2.f - 1.f, 0.f));
|
2017-06-01 19:10:06 +00:00
|
|
|
if (i != 111)
|
|
|
|
verts.push_back(verts.back());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(),
|
|
|
|
sizeof(zeus::CVector3f), verts.size());
|
|
|
|
}
|
|
|
|
|
2016-07-27 19:07:46 +00:00
|
|
|
void CBooRenderer::LoadThermoPalette()
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
|
|
|
m_thermoPaletteTex = xc_store.GetObj("TXTR_ThermoPalette");
|
|
|
|
CTexture* thermoTexObj = m_thermoPaletteTex.GetObj();
|
|
|
|
if (thermoTexObj)
|
2016-08-03 21:53:03 +00:00
|
|
|
x288_thermoPalette = thermoTexObj->GetPaletteTexture();
|
2016-07-25 22:52:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 07:57:12 +00:00
|
|
|
void CBooRenderer::LoadBallFade()
|
|
|
|
{
|
|
|
|
m_ballFadeTex = xc_store.GetObj("TXTR_BallFade");
|
|
|
|
CTexture* ballFadeTexObj = m_ballFadeTex.GetObj();
|
|
|
|
if (ballFadeTexObj)
|
|
|
|
m_ballFade = ballFadeTexObj->GetBooTexture();
|
|
|
|
}
|
|
|
|
|
2016-07-22 02:32:23 +00:00
|
|
|
CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
|
2016-07-25 22:52:02 +00:00
|
|
|
: x8_factory(resFac), xc_store(store), x2a8_thermalRand(20)
|
2016-07-22 02:32:23 +00:00
|
|
|
{
|
2016-08-03 21:53:03 +00:00
|
|
|
g_Renderer = this;
|
2016-07-25 22:52:02 +00:00
|
|
|
xee_24_ = true;
|
|
|
|
|
2017-06-01 19:10:06 +00:00
|
|
|
m_staticEntropy = store.GetObj("RandomStaticEntropy");
|
|
|
|
|
2017-11-05 06:17:12 +00:00
|
|
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
2016-07-25 22:52:02 +00:00
|
|
|
{
|
|
|
|
GenerateFogVolumeRampTex(ctx);
|
|
|
|
GenerateSphereRampTex(ctx);
|
2017-10-01 04:26:46 +00:00
|
|
|
m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0);
|
2017-11-12 05:14:57 +00:00
|
|
|
x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::Repeat, 1, 0);
|
2017-06-01 19:10:06 +00:00
|
|
|
GenerateScanLinesVBO(ctx);
|
2016-07-25 22:52:02 +00:00
|
|
|
return true;
|
|
|
|
});
|
2016-07-27 19:07:46 +00:00
|
|
|
LoadThermoPalette();
|
2017-03-05 07:57:12 +00:00
|
|
|
LoadBallFade();
|
2016-08-03 21:53:03 +00:00
|
|
|
m_thermHotFilter.emplace();
|
2016-07-25 22:52:02 +00:00
|
|
|
|
|
|
|
Buckets::Init();
|
2017-03-14 07:03:58 +00:00
|
|
|
|
|
|
|
m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.end();
|
|
|
|
m_nextFogVolumeFilter = m_fogVolumeFilters.end();
|
2016-07-22 02:32:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
void CBooRenderer::AddWorldSurfaces(CBooModel& model)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-26 22:05:59 +00:00
|
|
|
CBooSurface* surf = model.x3c_firstSortedSurface;
|
|
|
|
while (surf)
|
|
|
|
{
|
2017-11-19 23:48:09 +00:00
|
|
|
const MaterialSet::Material& mat = model.GetMaterialByIndex(surf->m_data.matIdx);
|
2016-07-26 22:05:59 +00:00
|
|
|
zeus::CAABox aabb = surf->GetBounds();
|
2016-07-28 04:55:06 +00:00
|
|
|
zeus::CVector3f pt = aabb.closestPointAlongVector(xb0_viewPlane.vec);
|
2016-08-03 21:53:03 +00:00
|
|
|
Buckets::Insert(pt, aabb, EDrawableType::WorldSurface, surf, xb0_viewPlane,
|
2016-07-26 22:05:59 +00:00
|
|
|
mat.heclIr.m_blendDst != boo::BlendFactor::Zero);
|
|
|
|
surf = surf->m_next;
|
|
|
|
}
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
std::list<CBooRenderer::CAreaListItem>::iterator
|
|
|
|
CBooRenderer::FindStaticGeometry(const std::vector<CMetroidModelInstance>* geometry)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-26 22:05:59 +00:00
|
|
|
return std::find_if(x1c_areaListItems.begin(), x1c_areaListItems.end(),
|
|
|
|
[&](CAreaListItem& item) -> bool {return item.x0_geometry == geometry;});
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry,
|
2017-11-19 23:48:09 +00:00
|
|
|
const CAreaRenderOctTree* octTree, int areaIdx,
|
|
|
|
const SShader* shaderSet)
|
2016-07-26 22:05:59 +00:00
|
|
|
{
|
|
|
|
auto search = FindStaticGeometry(geometry);
|
|
|
|
if (search == x1c_areaListItems.end())
|
|
|
|
{
|
2017-03-03 07:18:12 +00:00
|
|
|
std::vector<TCachedToken<CTexture>> textures;
|
2016-07-26 22:05:59 +00:00
|
|
|
std::vector<CBooModel*> models;
|
|
|
|
if (geometry->size())
|
|
|
|
{
|
2017-03-03 07:18:12 +00:00
|
|
|
(*geometry)[0].m_instance->MakeTexturesFromMats(textures, xc_store);
|
2016-07-26 22:05:59 +00:00
|
|
|
models.reserve(geometry->size());
|
2017-03-07 05:36:02 +00:00
|
|
|
int instIdx = 0;
|
2016-07-26 22:05:59 +00:00
|
|
|
for (const CMetroidModelInstance& inst : *geometry)
|
2017-03-07 05:36:02 +00:00
|
|
|
{
|
2017-04-18 23:41:01 +00:00
|
|
|
models.push_back(inst.m_instance.get());
|
2017-03-07 05:36:02 +00:00
|
|
|
models.back()->x44_areaInstanceIdx = instIdx++;
|
|
|
|
}
|
2016-07-26 22:05:59 +00:00
|
|
|
}
|
2017-11-19 23:48:09 +00:00
|
|
|
x1c_areaListItems.emplace_back(geometry, octTree, std::move(textures), std::move(models), areaIdx, shaderSet);
|
2016-07-26 22:05:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 04:26:46 +00:00
|
|
|
void CBooRenderer::EnablePVS(const CPVSVisSet& set, u32 areaIdx)
|
2016-07-27 23:06:57 +00:00
|
|
|
{
|
2017-10-01 04:26:46 +00:00
|
|
|
xc8_pvs.emplace(set);
|
2017-03-06 06:33:51 +00:00
|
|
|
xe0_pvsAreaIdx = areaIdx;
|
2016-07-27 23:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::DisablePVS()
|
|
|
|
{
|
|
|
|
xc8_pvs = std::experimental::nullopt;
|
|
|
|
}
|
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
void CBooRenderer::UpdateAreaUniforms(int areaIdx)
|
|
|
|
{
|
|
|
|
SetupRendererStates();
|
|
|
|
|
2017-11-19 23:48:09 +00:00
|
|
|
CModelFlags flags;
|
|
|
|
flags.m_extendedShader = EExtendedShader::Lighting;
|
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
for (CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
|
|
|
continue;
|
|
|
|
|
2017-11-19 23:48:09 +00:00
|
|
|
item.m_shaderSet->m_geomLayout->Update(flags, nullptr, nullptr, &item.m_shaderSet->m_matSet,
|
|
|
|
item.m_shaderSet->m_geomLayout->m_sharedBuffer);
|
|
|
|
|
2017-11-12 05:14:57 +00:00
|
|
|
for (auto it = item.x10_models.begin(); it != item.x10_models.end(); ++it)
|
|
|
|
{
|
|
|
|
CBooModel* model = *it;
|
|
|
|
if (model->TryLockTextures())
|
|
|
|
{
|
|
|
|
ActivateLightsForModel(&item, *model);
|
|
|
|
model->UpdateUniformData(flags, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
void CBooRenderer::RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry)
|
|
|
|
{
|
|
|
|
auto search = FindStaticGeometry(geometry);
|
|
|
|
if (search != x1c_areaListItems.end())
|
|
|
|
x1c_areaListItems.erase(search);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 06:33:51 +00:00
|
|
|
void CBooRenderer::DrawAreaGeometry(int areaIdx, int mask, int targetMask)
|
|
|
|
{
|
|
|
|
x318_30_inAreaDraw = true;
|
2017-11-12 05:14:57 +00:00
|
|
|
//SetupRendererStates();
|
2017-03-06 06:33:51 +00:00
|
|
|
CModelFlags flags;
|
|
|
|
|
|
|
|
for (CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (areaIdx != -1 || item.x18_areaIdx == areaIdx)
|
|
|
|
{
|
|
|
|
CPVSVisSet* pvs = xc8_pvs ? &*xc8_pvs : nullptr;
|
|
|
|
if (xe0_pvsAreaIdx != item.x18_areaIdx)
|
|
|
|
pvs = nullptr;
|
|
|
|
int modelIdx = 0;
|
|
|
|
for (auto it = item.x10_models.begin() ; it != item.x10_models.end() ; ++it, ++modelIdx)
|
|
|
|
{
|
|
|
|
CBooModel* model = *it;
|
|
|
|
if (pvs)
|
|
|
|
{
|
|
|
|
bool visible = pvs->GetVisible(modelIdx) != EPVSVisSetState::EndOfTree;
|
|
|
|
if ((xc4_pvsMode == EPVSMode::PVS && !visible) || (xc4_pvsMode == EPVSMode::PVSAndMask && visible))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((model->x41_mask & mask) != targetMask)
|
|
|
|
continue;
|
|
|
|
if (!x44_frustumPlanes.aabbFrustumTest(model->x20_aabb))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (const CBooSurface* surf = model->x38_firstUnsortedSurface ; surf ; surf = surf->m_next)
|
|
|
|
model->DrawSurface(*surf, flags);
|
|
|
|
for (const CBooSurface* surf = model->x3c_firstSortedSurface ; surf ; surf = surf->m_next)
|
|
|
|
model->DrawSurface(*surf, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x318_30_inAreaDraw = false;
|
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
//SetupRendererStates();
|
2016-07-27 23:06:57 +00:00
|
|
|
CAreaListItem* lastOctreeItem = nullptr;
|
|
|
|
|
|
|
|
for (CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
2016-07-27 23:06:57 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (item.x4_octTree)
|
|
|
|
lastOctreeItem = &item;
|
|
|
|
|
|
|
|
CPVSVisSet* pvs = nullptr;
|
|
|
|
if (xc8_pvs)
|
|
|
|
pvs = &*xc8_pvs;
|
2017-11-21 10:36:18 +00:00
|
|
|
if (xe0_pvsAreaIdx != item.x18_areaIdx)
|
2016-07-27 23:06:57 +00:00
|
|
|
pvs = nullptr;
|
|
|
|
|
2017-02-19 09:27:01 +00:00
|
|
|
u32 idx = 0;
|
2016-07-27 23:06:57 +00:00
|
|
|
for (auto it = item.x10_models.begin() ; it != item.x10_models.end() ; ++it, ++idx)
|
|
|
|
{
|
|
|
|
CBooModel* model = *it;
|
|
|
|
if (pvs)
|
|
|
|
{
|
2017-02-19 09:27:01 +00:00
|
|
|
bool vis = pvs->GetVisible(idx) != EPVSVisSetState::EndOfTree;
|
2016-07-27 23:06:57 +00:00
|
|
|
switch (xc4_pvsMode)
|
|
|
|
{
|
|
|
|
case EPVSMode::PVS:
|
|
|
|
{
|
|
|
|
if (!vis)
|
|
|
|
{
|
|
|
|
model->x40_25_modelVisible = false;
|
|
|
|
continue;
|
|
|
|
}
|
2016-07-28 04:55:06 +00:00
|
|
|
break;
|
2016-07-27 23:06:57 +00:00
|
|
|
}
|
|
|
|
case EPVSMode::PVSAndMask:
|
|
|
|
{
|
|
|
|
if (!vis && (model->x41_mask & mask) != targetMask)
|
|
|
|
{
|
|
|
|
model->x40_25_modelVisible = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((model->x41_mask & mask) != targetMask)
|
|
|
|
{
|
|
|
|
model->x40_25_modelVisible = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!x44_frustumPlanes.aabbFrustumTest(model->x20_aabb))
|
|
|
|
{
|
2017-11-21 22:18:52 +00:00
|
|
|
model->x40_25_modelVisible = false;
|
|
|
|
continue;
|
2016-07-27 23:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x318_25_drawWireframe)
|
|
|
|
{
|
|
|
|
model->x40_25_modelVisible = false;
|
|
|
|
//HandleUnsortedModelWireframe();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
model->x40_25_modelVisible = true;
|
2016-07-28 04:55:06 +00:00
|
|
|
HandleUnsortedModel(lastOctreeItem, *model);
|
2016-07-27 23:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//SetupCGraphicsStates();
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-11-12 05:14:57 +00:00
|
|
|
//SetupRendererStates();
|
2016-07-28 04:55:06 +00:00
|
|
|
|
|
|
|
CAreaListItem* lastOctreeItem = nullptr;
|
|
|
|
|
|
|
|
for (CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (item.x4_octTree)
|
|
|
|
lastOctreeItem = &item;
|
|
|
|
|
|
|
|
for (auto it = item.x10_models.begin() ; it != item.x10_models.end() ; ++it)
|
|
|
|
{
|
|
|
|
CBooModel* model = *it;
|
|
|
|
if (model->x40_25_modelVisible)
|
|
|
|
AddWorldSurfaces(*model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Buckets::Sort();
|
|
|
|
RenderBucketItems(lastOctreeItem);
|
|
|
|
|
|
|
|
//SetupCGraphicsStates();
|
|
|
|
//DrawRenderBucketsDebug();
|
|
|
|
Buckets::Clear();
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::DrawStaticGeometry(int modelCount, int mask, int targetMask)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
DrawUnsortedGeometry(modelCount, mask, targetMask);
|
|
|
|
DrawSortedGeometry(modelCount, mask, targetMask);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-06 05:21:42 +00:00
|
|
|
void CBooRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly)
|
|
|
|
{
|
|
|
|
model.GetInstance().DrawFlat(unsortedOnly ?
|
|
|
|
CBooModel::ESurfaceSelection::UnsortedOnly :
|
|
|
|
CBooModel::ESurfaceSelection::All,
|
|
|
|
flags.m_extendedShader);
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:21:45 +00:00
|
|
|
void CBooRenderer::PostRenderFogs()
|
|
|
|
{
|
2017-03-07 05:36:02 +00:00
|
|
|
for (const auto& warp : x2c4_spaceWarps)
|
|
|
|
DrawSpaceWarp(warp.first, warp.second);
|
|
|
|
x2c4_spaceWarps.clear();
|
|
|
|
|
|
|
|
x2ac_fogVolumes.sort([](const CFogVolumeListItem& a, const CFogVolumeListItem& b)
|
|
|
|
{
|
|
|
|
zeus::CAABox aabbA = a.x34_aabb.getTransformedAABox(a.x0_transform);
|
|
|
|
bool insideA = aabbA.pointInside(zeus::CVector3f(CGraphics::g_ViewPoint.x, CGraphics::g_ViewPoint.y, aabbA.min.z));
|
|
|
|
|
|
|
|
zeus::CAABox aabbB = b.x34_aabb.getTransformedAABox(b.x0_transform);
|
|
|
|
bool insideB = aabbB.pointInside(zeus::CVector3f(CGraphics::g_ViewPoint.x, CGraphics::g_ViewPoint.y, aabbB.min.z));
|
|
|
|
|
|
|
|
if (insideA != insideB)
|
|
|
|
return insideA;
|
|
|
|
|
|
|
|
float dotA = aabbA.furthestPointAlongVector(CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
|
|
|
float dotB = aabbB.furthestPointAlongVector(CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
|
|
|
return dotA < dotB;
|
|
|
|
});
|
|
|
|
for (const CFogVolumeListItem& fog : x2ac_fogVolumes)
|
|
|
|
{
|
|
|
|
CGraphics::SetModelMatrix(fog.x0_transform);
|
|
|
|
ReallyRenderFogVolume(fog.x30_color, fog.x34_aabb, fog.x4c_model.GetObj(), fog.x5c_skinnedModel);
|
|
|
|
}
|
|
|
|
x2ac_fogVolumes.clear();
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
void CBooRenderer::AddParticleGen(const CParticleGen& gen)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
auto bounds = gen.GetBounds();
|
|
|
|
if (bounds)
|
2016-07-26 22:05:59 +00:00
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.vec);
|
|
|
|
Buckets::Insert(pt, bounds.value(), EDrawableType::Particle, &gen, xb0_viewPlane, 0);
|
2016-07-26 22:05:59 +00:00
|
|
|
}
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::AddPlaneObject(const void*, const zeus::CAABox&, const zeus::CPlane&, int)
|
|
|
|
{
|
2016-07-26 22:05:59 +00:00
|
|
|
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
void CBooRenderer::AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, EDrawableSorting sorting)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-26 22:05:59 +00:00
|
|
|
if (sorting == EDrawableSorting::UnsortedCallback)
|
2016-07-28 04:55:06 +00:00
|
|
|
xa8_drawableCallback(obj, xac_callbackContext, mode);
|
2016-07-26 22:05:59 +00:00
|
|
|
else
|
2016-07-28 04:55:06 +00:00
|
|
|
Buckets::Insert(pos, aabb, EDrawableType(mode + 2), obj, xb0_viewPlane, 0);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 04:31:08 +00:00
|
|
|
void CBooRenderer::SetDrawableCallback(TDrawableCallback cb, const void* ctx)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-03-04 04:31:08 +00:00
|
|
|
xa8_drawableCallback = cb;
|
2016-07-26 22:05:59 +00:00
|
|
|
xac_callbackContext = ctx;
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::SetWorldViewpoint(const zeus::CTransform& xf)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
CGraphics::SetViewPointMatrix(xf);
|
|
|
|
xb0_viewPlane.vec = xf.basis[1];
|
|
|
|
xb0_viewPlane.d = xf.basis[1].dot(xf.origin);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::SetPerspective(float fovy, float width, float height, float znear, float zfar)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
CGraphics::SetPerspective(fovy, width / height, znear, zfar);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-28 04:55:06 +00:00
|
|
|
void CBooRenderer::SetPerspective(float fovy, float aspect, float znear, float zfar)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-28 04:55:06 +00:00
|
|
|
CGraphics::SetPerspective(fovy, aspect, znear, zfar);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-06-01 05:34:24 +00:00
|
|
|
std::pair<zeus::CVector2f, zeus::CVector2f>
|
|
|
|
CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-06-01 05:34:24 +00:00
|
|
|
float left = centered ? g_Viewport.x0_left - g_Viewport.x10_halfWidth : 0.f;
|
|
|
|
float bottom = centered ? g_Viewport.x4_top - g_Viewport.x14_halfHeight : 0.f;
|
|
|
|
float top = centered ? g_Viewport.x0_left + g_Viewport.x14_halfHeight : g_Viewport.xc_height;
|
|
|
|
float right = centered ? g_Viewport.x4_top + g_Viewport.x10_halfWidth : g_Viewport.x8_width;
|
2016-07-29 17:38:44 +00:00
|
|
|
|
|
|
|
CGraphics::SetOrtho(left, right, top, bottom, znear, zfar);
|
|
|
|
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
2016-12-18 04:16:04 +00:00
|
|
|
|
2017-06-01 05:34:24 +00:00
|
|
|
return {{left, bottom}, {right, top}};
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-26 22:05:59 +00:00
|
|
|
void CBooRenderer::SetClippingPlanes(const zeus::CFrustum& frustum)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-26 22:05:59 +00:00
|
|
|
x44_frustumPlanes = frustum;
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 17:38:44 +00:00
|
|
|
void CBooRenderer::SetViewport(int l, int b, int w, int h)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-29 17:38:44 +00:00
|
|
|
CGraphics::SetViewport(l, b, w, h);
|
|
|
|
CGraphics::SetScissor(l, b, w, h);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::SetDebugOption(EDebugOption, int)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::BeginScene()
|
|
|
|
{
|
2017-03-03 07:18:12 +00:00
|
|
|
CGraphics::SetViewport(0, 0, g_Viewport.x8_width, g_Viewport.xc_height);
|
2016-07-29 17:38:44 +00:00
|
|
|
CGraphics::SetPerspective(75.f, CGraphics::g_ProjAspect, 1.f, 4096.f);
|
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
2017-05-06 05:21:42 +00:00
|
|
|
#if 0
|
|
|
|
if (x310_phazonSuitMaskCountdown != 0)
|
|
|
|
{
|
|
|
|
--x310_phazonSuitMaskCountdown;
|
|
|
|
if (x310_phazonSuitMaskCountdown == 0)
|
|
|
|
x314_phazonSuitMask.reset();
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-06 06:33:51 +00:00
|
|
|
x318_27_currentRGBA6 = x318_26_requestRGBA6;
|
|
|
|
if (!x318_31_persistRGBA6)
|
|
|
|
x318_26_requestRGBA6 = false;
|
|
|
|
//GXSetPixelFmt(x318_27_currentRGBA6);
|
2016-07-29 17:38:44 +00:00
|
|
|
CGraphics::BeginScene();
|
2017-03-14 07:03:58 +00:00
|
|
|
m_nextFogVolumePlaneShader = m_fogVolumePlaneShaders.begin();
|
|
|
|
m_nextFogVolumeFilter = m_fogVolumeFilters.begin();
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::EndScene()
|
|
|
|
{
|
2016-07-29 17:38:44 +00:00
|
|
|
CGraphics::EndScene();
|
2017-03-26 05:53:04 +00:00
|
|
|
if (x2dc_reflectionAge >= 2)
|
|
|
|
{
|
|
|
|
// Delete reflection tex x14c_
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++x2dc_reflectionAge;
|
|
|
|
}
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 17:38:44 +00:00
|
|
|
void CBooRenderer::SetAmbientColor(const zeus::CColor& color)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-29 17:38:44 +00:00
|
|
|
CGraphics::SetAmbientColor(color);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::DrawString(const char*, int, int)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CBooRenderer::GetFPS()
|
|
|
|
{
|
2016-07-24 06:05:12 +00:00
|
|
|
return 0;
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-26 05:53:04 +00:00
|
|
|
void CBooRenderer::CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter)
|
|
|
|
{
|
|
|
|
if (!x318_24_refectionDirty)
|
|
|
|
return;
|
|
|
|
x318_24_refectionDirty = false;
|
|
|
|
x2dc_reflectionAge = 0;
|
|
|
|
|
|
|
|
BindReflectionDrawTarget();
|
|
|
|
SViewport backupVp = g_Viewport;
|
|
|
|
SetViewport(0, 0, 256, 256);
|
|
|
|
CGraphics::g_BooMainCommandQueue->clearTarget();
|
|
|
|
cb(ctx, CBooModel::g_ReflectViewPos);
|
|
|
|
boo::SWindowRect rect(0, 0, 256, 256);
|
|
|
|
CGraphics::g_BooMainCommandQueue->resolveBindTexture(x14c_reflectionTex, rect, false, 0, true, false);
|
|
|
|
BindMainDrawTarget();
|
|
|
|
SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
|
|
|
}
|
|
|
|
|
2016-07-31 02:06:47 +00:00
|
|
|
void CBooRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-31 02:06:47 +00:00
|
|
|
m_spaceWarpFilter.setStrength(strength);
|
|
|
|
m_spaceWarpFilter.draw(pt);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-31 02:06:47 +00:00
|
|
|
void CBooRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& mulCol, const zeus::CColor& addCol)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-31 04:46:03 +00:00
|
|
|
CModelFlags flags;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::Thermal;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color = mulCol;
|
2016-07-31 04:46:03 +00:00
|
|
|
flags.addColor = addCol;
|
2017-03-10 03:40:24 +00:00
|
|
|
model.UpdateLastFrame();
|
2016-07-31 04:46:03 +00:00
|
|
|
model.Draw(flags);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-08-07 00:20:02 +00:00
|
|
|
void CBooRenderer::DrawXRayOutline(const zeus::CAABox& aabb)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-08-07 00:20:02 +00:00
|
|
|
CModelFlags flags;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
2016-08-07 00:20:02 +00:00
|
|
|
|
2016-08-05 20:26:23 +00:00
|
|
|
for (CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (item.x4_octTree)
|
|
|
|
{
|
2016-08-07 00:20:02 +00:00
|
|
|
std::vector<u32> bitmap;
|
|
|
|
item.x4_octTree->FindOverlappingModels(bitmap, aabb);
|
|
|
|
|
|
|
|
for (u32 c=0 ; c<item.x4_octTree->x14_bitmapWordCount ; ++c)
|
|
|
|
{
|
|
|
|
for (u32 b=0 ; b<32 ; ++b)
|
|
|
|
{
|
|
|
|
if (bitmap[c] & (1 << b))
|
|
|
|
{
|
|
|
|
CBooModel* model = item.x10_models[c * 32 + b];
|
2016-08-21 20:39:18 +00:00
|
|
|
model->UpdateUniformData(flags, nullptr, nullptr);
|
2016-08-07 00:20:02 +00:00
|
|
|
const CBooSurface* surf = model->x38_firstUnsortedSurface;
|
|
|
|
while (surf)
|
|
|
|
{
|
|
|
|
if (surf->GetBounds().intersects(aabb))
|
|
|
|
model->DrawSurface(*surf, flags);
|
|
|
|
surf = surf->m_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-05 20:26:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::SetWireframeFlags(int)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-08 04:48:18 +00:00
|
|
|
void CBooRenderer::SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-08-08 04:48:18 +00:00
|
|
|
if (x318_28_disableFog)
|
|
|
|
mode = ERglFogMode::None;
|
|
|
|
CGraphics::SetFog(mode, startz, endz, color);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-08-13 07:56:35 +00:00
|
|
|
void CBooRenderer::RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
|
|
|
|
const TLockedToken<CModel>* model, const CSkinnedModel* sModel)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2017-08-13 07:56:35 +00:00
|
|
|
if (!x318_28_disableFog)
|
|
|
|
x2ac_fogVolumes.emplace_back(CGraphics::g_GXModelMatrix, color, aabb, model, sModel);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-31 02:06:47 +00:00
|
|
|
void CBooRenderer::SetThermal(bool thermal, float level, const zeus::CColor& color)
|
2016-07-21 05:21:45 +00:00
|
|
|
{
|
2016-07-31 02:06:47 +00:00
|
|
|
x318_29_thermalVisor = thermal;
|
|
|
|
x2f0_thermalVisorLevel = level;
|
|
|
|
x2f4_thermColor = color;
|
2017-01-22 17:36:25 +00:00
|
|
|
CDecal::SetMoveRedToAlphaBuffer(false);
|
|
|
|
CElementGen::SetMoveRedToAlphaBuffer(false);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2016-07-22 19:46:30 +00:00
|
|
|
void CBooRenderer::SetThermalColdScale(float scale)
|
|
|
|
{
|
|
|
|
x2f8_thermColdScale = zeus::clamp(0.f, scale, 1.f);
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:21:45 +00:00
|
|
|
void CBooRenderer::DoThermalBlendCold()
|
2016-08-17 20:05:23 +00:00
|
|
|
{
|
2016-07-25 22:52:02 +00:00
|
|
|
zeus::CColor a = zeus::CColor::lerp(x2f4_thermColor, zeus::CColor::skWhite, x2f8_thermColdScale);
|
|
|
|
m_thermColdFilter.setColorA(a);
|
|
|
|
float bFac = 0.f;
|
|
|
|
float bAlpha = 1.f;
|
|
|
|
if (x2f8_thermColdScale < 0.5f)
|
|
|
|
{
|
|
|
|
bAlpha = x2f8_thermColdScale * 2.f;
|
|
|
|
bFac = (1.f - bAlpha) / 8.f;
|
|
|
|
}
|
|
|
|
zeus::CColor b{bFac, bFac, bFac, bAlpha};
|
|
|
|
m_thermColdFilter.setColorB(b);
|
|
|
|
zeus::CColor c = zeus::CColor::lerp(zeus::CColor::skBlack, zeus::CColor::skWhite,
|
2016-07-28 04:55:06 +00:00
|
|
|
zeus::clamp(0.f, (x2f8_thermColdScale - 0.25f) * 4.f / 3.f, 1.f));
|
2016-07-25 22:52:02 +00:00
|
|
|
m_thermColdFilter.setColorC(c);
|
|
|
|
|
|
|
|
m_thermColdFilter.setScale(x2f8_thermColdScale);
|
|
|
|
|
|
|
|
m_thermColdFilter.setShift(x2a8_thermalRand.Next() % 32);
|
|
|
|
m_thermColdFilter.draw();
|
2017-01-22 17:36:25 +00:00
|
|
|
CElementGen::SetMoveRedToAlphaBuffer(true);
|
|
|
|
CDecal::SetMoveRedToAlphaBuffer(true);
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::DoThermalBlendHot()
|
|
|
|
{
|
2016-08-03 21:53:03 +00:00
|
|
|
m_thermHotFilter->draw();
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 CBooRenderer::GetStaticWorldDataSize()
|
|
|
|
{
|
2016-07-24 06:05:12 +00:00
|
|
|
return 0;
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 07:18:12 +00:00
|
|
|
void CBooRenderer::PrepareDynamicLights(const std::vector<CLight>& lights)
|
|
|
|
{
|
|
|
|
x300_dynamicLights = lights;
|
|
|
|
for (CAreaListItem& area : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (const CAreaRenderOctTree* arot = area.x4_octTree)
|
|
|
|
{
|
|
|
|
area.x1c_lightOctreeWords.clear();
|
|
|
|
area.x1c_lightOctreeWords.resize(arot->x14_bitmapWordCount * lights.size());
|
|
|
|
u32* wordPtr = area.x1c_lightOctreeWords.data();
|
|
|
|
for (const CLight& light : lights)
|
|
|
|
{
|
|
|
|
float radius = light.GetRadius();
|
|
|
|
zeus::CVector3f vMin = light.GetPosition() - radius;
|
|
|
|
zeus::CVector3f vMax = light.GetPosition() + radius;
|
|
|
|
zeus::CAABox aabb(vMin, vMax);
|
|
|
|
arot->FindOverlappingModels(wordPtr, aabb);
|
|
|
|
wordPtr += arot->x14_bitmapWordCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:28:31 +00:00
|
|
|
void CBooRenderer::SetWorldLightMultiplyColor(const zeus::CColor& color)
|
|
|
|
{
|
|
|
|
CGraphics::g_ColorRegs[1] = color;
|
|
|
|
}
|
|
|
|
|
2017-03-04 04:31:08 +00:00
|
|
|
void CBooRenderer::SetWorldLightFadeLevel(float level)
|
|
|
|
{
|
|
|
|
x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f);
|
|
|
|
}
|
|
|
|
|
2017-05-06 05:21:42 +00:00
|
|
|
void CBooRenderer::ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertColor, /*const CTexture& maskTex,*/
|
|
|
|
const CTexture& indTex, const zeus::CColor& modColor,
|
|
|
|
float scale, float offX, float offY)
|
|
|
|
{
|
2017-12-20 06:06:54 +00:00
|
|
|
float qScale = scale / 8.f; // Adjustment for URDE
|
|
|
|
m_phazonSuitFilter.draw(modColor, scale, offX * qScale, offY * qScale);
|
2017-05-06 05:21:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::ReallyDrawPhazonSuitEffect(const zeus::CColor& modColor /*, const CTexture& maskTex*/)
|
|
|
|
{
|
|
|
|
m_phazonSuitFilter.draw(modColor, 0.f, 0.f, 0.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::DoPhazonSuitIndirectAlphaBlur(float blurRadius /*, float f2*/, const TLockedToken<CTexture>& indTex)
|
|
|
|
{
|
|
|
|
m_phazonSuitFilter.drawBlurPasses(blurRadius, indTex.IsLoaded() ? indTex.GetObj() : nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod, const TLockedToken<CTexture>& indTex,
|
|
|
|
const zeus::CColor& indirectMod, float blurRadius,
|
|
|
|
float scale, float offX, float offY)
|
|
|
|
{
|
|
|
|
/* Indirect background already in binding 0 */
|
|
|
|
|
|
|
|
/* Resolve alpha channel of just-drawn phazon suit into binding 1 */
|
2017-05-21 16:01:04 +00:00
|
|
|
SClipScreenRect rect(g_Viewport);
|
2017-05-06 05:21:42 +00:00
|
|
|
CGraphics::ResolveSpareTexture(rect, 1);
|
|
|
|
|
|
|
|
/* Perform blur filter and resolve into binding 2 */
|
|
|
|
DoPhazonSuitIndirectAlphaBlur(blurRadius, indTex);
|
|
|
|
|
|
|
|
/* Draw effect; subtracting binding 1 from binding 2 for the filter 'cutout' */
|
|
|
|
if (indTex && indTex.IsLoaded())
|
|
|
|
ReallyDrawPhazonSuitIndirectEffect(zeus::CColor::skWhite, *indTex, indirectMod, scale, offX, offY);
|
|
|
|
else
|
|
|
|
ReallyDrawPhazonSuitEffect(nonIndirectMod);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBooRenderer::AllocatePhazonSuitMaskTexture()
|
|
|
|
{
|
|
|
|
x318_26_requestRGBA6 = true;
|
|
|
|
x310_phazonSuitMaskCountdown = 2;
|
|
|
|
}
|
|
|
|
|
2017-03-05 07:57:12 +00:00
|
|
|
void CBooRenderer::FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const
|
|
|
|
{
|
|
|
|
u32 bitmapWords = 0;
|
|
|
|
for (const CAreaListItem& item : x1c_areaListItems)
|
|
|
|
if (item.x4_octTree)
|
|
|
|
bitmapWords += item.x4_octTree->x14_bitmapWordCount;
|
|
|
|
|
|
|
|
if (!bitmapWords)
|
|
|
|
{
|
|
|
|
modelBits.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
modelBits.clear();
|
|
|
|
modelBits.resize(bitmapWords);
|
|
|
|
|
|
|
|
u32 curWord = 0;
|
|
|
|
for (const CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (!item.x4_octTree)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
item.x4_octTree->FindOverlappingModels(modelBits.data() + curWord, aabb);
|
|
|
|
|
|
|
|
u32 wordModel = 0;
|
|
|
|
for (int i=0 ; i<item.x4_octTree->x14_bitmapWordCount ; ++i, wordModel += 32)
|
|
|
|
{
|
|
|
|
u32& word = modelBits[i];
|
|
|
|
if (!word)
|
|
|
|
continue;
|
|
|
|
for (int j=0 ; j<32 ; ++j)
|
|
|
|
{
|
|
|
|
if ((1 << j) & word)
|
|
|
|
{
|
|
|
|
const zeus::CAABox& modelAABB = item.x10_models[wordModel + j]->x20_aabb;
|
|
|
|
if (!modelAABB.intersects(aabb))
|
|
|
|
word &= ~(1 << j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curWord += item.x4_octTree->x14_bitmapWordCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u32>& modelBits,
|
|
|
|
const zeus::CAABox& aabb) const
|
|
|
|
{
|
2017-04-13 19:28:31 +00:00
|
|
|
SetupRendererStates();
|
2017-11-12 05:14:57 +00:00
|
|
|
const_cast<CBooRenderer&>(*this).UpdateAreaUniforms(-1);
|
2017-04-13 19:28:31 +00:00
|
|
|
|
2017-03-06 06:33:51 +00:00
|
|
|
CModelFlags flags;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::SolidColor; // Do solid color draw
|
2017-03-05 07:57:12 +00:00
|
|
|
|
|
|
|
u32 curWord = 0;
|
|
|
|
for (const CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (!item.x4_octTree)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
u32 wordModel = 0;
|
|
|
|
for (int i=0 ; i<item.x4_octTree->x14_bitmapWordCount ; ++i, wordModel += 32)
|
|
|
|
{
|
|
|
|
const u32& word = modelBits[i];
|
|
|
|
if (!word)
|
|
|
|
continue;
|
|
|
|
for (int j=0 ; j<32 ; ++j)
|
|
|
|
{
|
|
|
|
if ((1 << j) & word)
|
|
|
|
{
|
|
|
|
if (alphaVal > 255)
|
|
|
|
return alphaVal;
|
|
|
|
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color.a = alphaVal / 255.f;
|
2017-03-05 07:57:12 +00:00
|
|
|
const CBooModel& model = *item.x10_models[wordModel + j];
|
|
|
|
const_cast<CBooModel&>(model).VerifyCurrentShader(0);
|
|
|
|
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
|
|
|
if (surf->GetBounds().intersects(aabb))
|
|
|
|
model.DrawSurface(*surf, flags);
|
|
|
|
alphaVal += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curWord += item.x4_octTree->x14_bitmapWordCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
return alphaVal;
|
|
|
|
}
|
|
|
|
|
2017-03-06 06:33:51 +00:00
|
|
|
void CBooRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vector<u32>& modelBits,
|
|
|
|
const zeus::CAABox& aabb, float alpha) const
|
|
|
|
{
|
|
|
|
CModelFlags flags;
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color.a = alpha;
|
2017-03-10 20:52:53 +00:00
|
|
|
flags.m_extendedShader = EExtendedShader::MorphBallShadow; // Do shadow draw
|
2017-03-06 06:33:51 +00:00
|
|
|
|
|
|
|
u32 curWord = 0;
|
|
|
|
for (const CAreaListItem& item : x1c_areaListItems)
|
|
|
|
{
|
|
|
|
if (!item.x4_octTree)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
u32 wordModel = 0;
|
|
|
|
for (int i=0 ; i<item.x4_octTree->x14_bitmapWordCount ; ++i, wordModel += 32)
|
|
|
|
{
|
|
|
|
const u32& word = modelBits[i];
|
|
|
|
if (!word)
|
|
|
|
continue;
|
|
|
|
for (int j=0 ; j<32 ; ++j)
|
|
|
|
{
|
|
|
|
if ((1 << j) & word)
|
|
|
|
{
|
|
|
|
if (alphaVal > 255)
|
|
|
|
return;
|
|
|
|
|
2017-03-20 05:09:53 +00:00
|
|
|
flags.x4_color.r = alphaVal / 255.f;
|
2017-03-06 06:33:51 +00:00
|
|
|
const CBooModel& model = *item.x10_models[wordModel + j];
|
|
|
|
const_cast<CBooModel&>(model).VerifyCurrentShader(0);
|
|
|
|
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
|
|
|
if (surf->GetBounds().intersects(aabb))
|
|
|
|
model.DrawSurface(*surf, flags);
|
|
|
|
alphaVal += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curWord += item.x4_octTree->x14_bitmapWordCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:21:45 +00:00
|
|
|
}
|