Actually remove trailing tabs from source/.

This was SVN commit r18991.
This commit is contained in:
elexis 2016-11-23 14:09:58 +00:00
parent c49c665edb
commit 417c84870c
166 changed files with 955 additions and 955 deletions

View File

@ -226,4 +226,4 @@ function markForPluralTranslation(singularMessage, pluralMessage, number)
"pluralCount": number
};
}

View File

@ -364,7 +364,7 @@ global.RunHardwareDetection = function(settings)
if (output.disable_allwater !== undefined)
Engine.SetDisableAllWater(output.disable_allwater);
if (output.disable_fancywater !== undefined)
Engine.SetDisableFancyWater(output.disable_fancywater);

View File

@ -201,7 +201,7 @@ void ReindexGeometry(FCDGeometryPolygons* polys, FCDSkinController* skin)
{
const float* dataTexcoord = texcoordSources[set]->GetData();
uint32 strideTexcoord = texcoordSources[set]->GetStride();
uv_pair_type p;
p.first = dataTexcoord[indicesTexcoord[i]*strideTexcoord];
p.second = dataTexcoord[indicesTexcoord[i]*strideTexcoord + 1];

View File

@ -96,7 +96,7 @@ static void AddStaticPropPoints(std::vector<PropPoint> &propPoints, const FMMatr
PropPoint p = {
propPointName,
// Flip translation across the x-axis by swapping y and z
{ parts.t.x, parts.t.z, parts.t.y },
@ -157,7 +157,7 @@ public:
FCDGeometrySource* sourcePosition = inputPosition->GetSource();
FCDGeometrySource* sourceNormal = inputNormal ->GetSource();
FCDGeometrySourceList texcoordSources;
polys->GetParent()->FindSourcesByType(FUDaeGeometryInput::TEXCOORD, texcoordSources);
@ -183,7 +183,7 @@ public:
// Default prop points are already given in game coordinates
AddDefaultPropPoints(propPoints);
// Calculate transform to convert from COLLADA-defined up_axis to Z-up because
// it's relatively straightforward to convert that to game coordinates
FMMatrix44 upAxisTransform = FMMatrix44_Identity;
@ -207,7 +207,7 @@ public:
// (NB: GetType is deprecated and should be replaced with HasType,
// except that has irritating linker errors when using a DLL, so don't
// bother)
assert(converter.GetInstance().GetEntity()->GetType() == FCDEntity::CONTROLLER); // assume this is always true?
FCDController* controller = static_cast<FCDController*>(converter.GetInstance().GetEntity());
@ -565,7 +565,7 @@ public:
if (! mesh->IsTriangles())
FCDGeometryPolygonsTools::Triangulate(mesh);
REQUIRE(mesh->IsTriangles(), "mesh is made of triangles");
REQUIRE(mesh->GetPolygonsCount() == 1, "mesh has single set of polygons");
FCDGeometryPolygons* polys = mesh->GetPolygons(0);

View File

@ -108,7 +108,7 @@ namespace
Bone b;
b.name = name;
std::string newTargetName = targetName;
if (targetSkeleton)
@ -151,7 +151,7 @@ namespace
std::unique_ptr<Skeleton> skeleton (new Skeleton());
std::string title (FUXmlParser::ReadNodeProperty(*skeletonNode, "title"));
skeleton->m->title = title;
if (IsEquivalent((*skeletonNode)->name, "standard_skeleton"))

View File

@ -103,7 +103,7 @@ void CCinemaManager::SetEnabled(bool enabled)
// while the cinematic is running (a message box is the top page in this case).
// It might be better to disable the whole GUI during the cinematic instead of a specific
// GUI object.
// sn - session gui object
IGUIObject *sn = g_GUI->FindObjectByName("sn");
CmpPtr<ICmpRangeManager> cmpRangeManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
@ -166,12 +166,12 @@ void CCinemaManager::Update(const float deltaRealTime)
if (m_CinematicSimulationData.m_PathQueue.empty() || !m_CinematicSimulationData.m_Enabled || m_CinematicSimulationData.m_Paused)
return;
if (HotkeyIsPressed("leave"))
{
// TODO: implement skip
}
m_CinematicSimulationData.m_PathQueue.front().Play(deltaRealTime);
}
@ -182,7 +182,7 @@ void CCinemaManager::Render()
DrawBars();
return;
}
if (!m_DrawPaths)
return;

View File

@ -97,7 +97,7 @@ public:
return INFO::OK;
if (!dll.IsLoaded() && !TryLoadDLL())
return ERR::FAIL;
return ERR::FAIL;
LOGMESSAGE("Hotloading skeleton definitions from '%s'", path.string8());
// Set the filename for the logger to report
@ -247,7 +247,7 @@ public:
return loaded;
}
/**
* Creates MD5 hash key from skeletons.xml info and COLLADA converter version,
* used to invalidate cached .pmd/psas
@ -387,7 +387,7 @@ VfsPath CColladaManager::GetLoadablePath(const VfsPath& pathnameNoExtension, Fil
{
// No valid cached version was found, and no source .dae exists
ENSURE(ret < 0);
// Check if source (uncached) .pmd/psa exists
sourcePath = pathnameNoExtension.ChangeExtension(extn);
if (m_VFS->GetFileInfo(sourcePath, NULL) != INFO::OK)

View File

@ -133,7 +133,7 @@ bool CFrustum::IsBoxVisible(const CVector3D& position, const CBoundingBoxAligned
FarPoint.X = m_aPlanes[i].m_Norm.X > 0.0f ? Max.X : Min.X;
FarPoint.Y = m_aPlanes[i].m_Norm.Y > 0.0f ? Max.Y : Min.Y;
FarPoint.Z = m_aPlanes[i].m_Norm.Z > 0.0f ? Max.Z : Min.Z;
if (m_aPlanes[i].IsPointOnBackSide(FarPoint))
return false;
}
@ -151,7 +151,7 @@ bool CFrustum::IsBoxVisible(const CBoundingBoxAligned& bounds) const
FarPoint.X = m_aPlanes[i].m_Norm.X > 0.0f ? bounds[1].X : bounds[0].X;
FarPoint.Y = m_aPlanes[i].m_Norm.Y > 0.0f ? bounds[1].Y : bounds[0].Y;
FarPoint.Z = m_aPlanes[i].m_Norm.Z > 0.0f ? bounds[1].Z : bounds[0].Z;
if (m_aPlanes[i].IsPointOnBackSide(FarPoint))
return false;
}

View File

@ -79,14 +79,14 @@ bool CLOSTexture::CreateShader()
CShaderProgramPtr shader = m_smoothShader->GetShader();
m_ShaderInitialized = m_smoothShader && shader;
if (!m_ShaderInitialized)
{
LOGERROR("Failed to load SmoothLOS shader, disabling.");
g_Renderer.m_Options.m_SmoothLOS = false;
return false;
}
pglGenFramebuffersEXT(1, &m_smoothFbo);
return true;
}
@ -159,7 +159,7 @@ void CLOSTexture::InterpolateLOS()
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_smoothFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
whichTex ? m_TextureSmooth2 : m_TextureSmooth1, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
@ -168,20 +168,20 @@ void CLOSTexture::InterpolateLOS()
m_smoothShader->BeginPass();
CShaderProgramPtr shader = m_smoothShader->GetShader();
glDisable(GL_BLEND);
shader->Bind();
shader->BindTexture(str_losTex1, m_Texture);
shader->BindTexture(str_losTex2, whichTex ? m_TextureSmooth1 : m_TextureSmooth2);
shader->Uniform(str_delta, (float)g_Renderer.GetTimeManager().GetFrameDelta() * 4.0f, 0.0f, 0.0f, 0.0f);
const SViewPort oldVp = g_Renderer.GetViewport();
const SViewPort vp = { 0, 0, m_TextureSize, m_TextureSize };
g_Renderer.SetViewport(vp);
float quadVerts[] = {
1.0f, 1.0f,
-1.0f, 1.0f,
@ -204,16 +204,16 @@ void CLOSTexture::InterpolateLOS()
shader->VertexPointer(2, GL_FLOAT, 0, quadVerts);
shader->AssertPointersBound();
glDrawArrays(GL_TRIANGLES, 0, 6);
g_Renderer.SetViewport(oldVp);
shader->Unbind();
m_smoothShader->EndPass();
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, originalFBO);
whichTex = !whichTex;
}
@ -257,12 +257,12 @@ void CLOSTexture::ConstructTexture(int unit)
// overwrite with glTexSubImage2D later
u8* texData = new u8[m_TextureSize * m_TextureSize * 4];
memset(texData, 0x00, m_TextureSize * m_TextureSize * 4);
if (CRenderer::IsInitialised() && g_Renderer.m_Options.m_SmoothLOS)
{
glGenTextures(1, &m_TextureSmooth1);
glGenTextures(1, &m_TextureSmooth2);
g_Renderer.BindTexture(unit, m_TextureSmooth1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TextureSize, m_TextureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -277,16 +277,16 @@ void CLOSTexture::ConstructTexture(int unit)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
g_Renderer.BindTexture(unit, m_Texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_TextureSize, m_TextureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
delete[] texData;
delete[] texData;
{
// Texture matrix: We want to map
// world pos (0, y, 0) (i.e. first vertex)
@ -348,9 +348,9 @@ void CLOSTexture::RecomputeTexture(int unit)
if (CRenderer::IsInitialised() && g_Renderer.m_Options.m_SmoothLOS && recreated)
{
g_Renderer.BindTexture(unit, m_TextureSmooth1);
g_Renderer.BindTexture(unit, m_TextureSmooth1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pitch, m_MapSize, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
g_Renderer.BindTexture(unit, m_TextureSmooth2);
g_Renderer.BindTexture(unit, m_TextureSmooth2);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pitch, m_MapSize, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
}

View File

@ -88,10 +88,10 @@ bool CMapGeneratorWorker::Run()
~AutoFree() { SAFE_DELETE(m_p); }
ScriptInterface* m_p;
} autoFree(m_ScriptInterface);
JSContext* cx = m_ScriptInterface->GetContext();
JSAutoRequest rq(cx);
m_ScriptInterface->SetCallbackData(static_cast<void*> (this));
// Replace RNG with a seeded deterministic function
@ -116,7 +116,7 @@ bool CMapGeneratorWorker::Run()
LOGERROR("CMapGeneratorWorker::Run: Failed to parse settings");
return false;
}
// Init RNG seed
u32 seed;
if (!m_ScriptInterface->GetProperty(settingsVal, "Seed", seed))
@ -228,7 +228,7 @@ CParamNode CMapGeneratorWorker::GetTemplate(ScriptInterface::CxPrivate* pCxPriva
const CParamNode& templateRoot = self->m_TemplateLoader.GetTemplateFileData(templateName).GetChild("Entity");
if (!templateRoot.IsOk())
LOGERROR("Invalid template found for '%s'", templateName.c_str());
return templateRoot;
}

View File

@ -412,7 +412,7 @@ void CMapWriter::WriteXML(const VfsPath& filename,
const std::vector<SplineData>& nodes = it->second.GetAllNodes();
const std::vector<SplineData>& target_nodes = it->second.GetTargetSpline().GetAllNodes();
const CCinemaData* data = it->second.GetData();
XML_Element("Path");
XML_Attribute("name", data->m_Name);
XML_Attribute("timescale", timescale);

View File

@ -81,10 +81,10 @@ CMaterial CMaterialManager::LoadMaterial(const VfsPath& pathname)
CMaterial material;
XMBElement root = xeroFile.GetRoot();
CPreprocessorWrapper preprocessor;
preprocessor.AddDefine("CFG_FORCE_ALPHATEST", g_Renderer.m_Options.m_ForceAlphaTest ? "1" : "0");
CVector4D vec(qualityLevel,0,0,0);
material.AddStaticUniform("qualityLevel", vec);
@ -101,12 +101,12 @@ CMaterial CMaterialManager::LoadMaterial(const VfsPath& pathname)
if (cond.empty())
continue;
else
{
{
if (cond.ToFloat() <= qualityLevel)
continue;
}
}
material = LoadMaterial(VfsPath("art/materials") / attrs.GetNamedItem(at_material).FromUTF8());
break;
}
@ -125,17 +125,17 @@ CMaterial CMaterialManager::LoadMaterial(const VfsPath& pathname)
else if (token == el_conditional_define)
{
std::vector<float> args;
CStr type = attrs.GetNamedItem(at_type).c_str();
int typeID = -1;
if (type == CStr("draw_range"))
{
typeID = DCOND_DISTANCE;
float valmin = -1.0f;
float valmax = -1.0f;
CStr conf = attrs.GetNamedItem(at_conf);
if (!conf.empty())
{
@ -147,34 +147,34 @@ CMaterial CMaterialManager::LoadMaterial(const VfsPath& pathname)
CStr dmin = attrs.GetNamedItem(at_min);
if (!dmin.empty())
valmin = attrs.GetNamedItem(at_min).ToFloat();
CStr dmax = attrs.GetNamedItem(at_max);
if (!dmax.empty())
valmax = attrs.GetNamedItem(at_max).ToFloat();
}
args.push_back(valmin);
args.push_back(valmax);
if (valmin >= 0.0f)
{
std::stringstream sstr;
sstr << valmin;
material.AddShaderDefine(CStrIntern(conf + "_MIN"), CStrIntern(sstr.str()));
}
if (valmax >= 0.0f)
{
{
std::stringstream sstr;
sstr << valmax;
material.AddShaderDefine(CStrIntern(conf + "_MAX"), CStrIntern(sstr.str()));
}
}
material.AddConditionalDefine(attrs.GetNamedItem(at_name).c_str(),
attrs.GetNamedItem(at_value).c_str(),
typeID, args);
}
}
else if (token == el_uniform)
{
std::stringstream str(attrs.GetNamedItem(at_value));

View File

@ -79,7 +79,7 @@ bool CModel::InitModel(const CModelDefPtr& modeldef)
ReleaseData();
m_pModelDef = modeldef;
size_t numBones = modeldef->GetNumBones();
if (numBones != 0)
{
@ -161,7 +161,7 @@ void CModel::CalcAnimatedObjectBounds(CSkeletonAnimDef* anim, CBoundingBoxAligne
// having to recalculate the size of the box.
CMatrix3D transform, oldtransform = GetTransform();
CModelAbstract* oldparent = m_Parent;
m_Parent = 0;
transform.SetIdentity();
CRenderableObject::SetTransform(transform);
@ -238,7 +238,7 @@ const CBoundingBoxAligned CModel::GetObjectSelectionBoundsRec()
// From this, it is clear that either O or B x O is the object-space transformation matrix of the prop. So,
// all we need to do is apply our own inverse world-transform T^(-1) to T' to get our desired result. Luckily,
// this is precomputed upon setting the transform matrix (see @ref SetTransform), so it is free to fetch.
CMatrix3D propObjectTransform = prop.m_Model->GetTransform(); // T'
propObjectTransform.Concatenate(GetInvTransform()); // T^(-1) x T'
@ -324,13 +324,13 @@ void CModel::ValidatePosition()
ENSURE(!m_Parent || m_Parent->m_PositionValid);
return;
}
if (m_Parent && !m_Parent->m_PositionValid)
{
// Make sure we don't base our calculations on
// a parent animation state that is out of date.
m_Parent->ValidatePosition();
// Parent will recursively call our validation.
ENSURE(m_PositionValid);
return;
@ -339,9 +339,9 @@ void CModel::ValidatePosition()
if (m_Anim && m_BoneMatrices)
{
// PROFILE( "generating bone matrices" );
ENSURE(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys());
m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime, m_BoneMatrices, !(m_Flags & MODELFLAG_NOLOOPANIMATION));
}
else if (m_BoneMatrices)
@ -379,7 +379,7 @@ void CModel::ValidatePosition()
// our own position is now valid; now we can safely update our props' positions without fearing
// that doing so will cause a revalidation of this model (see recursion above).
m_PositionValid = true;
// re-position and validate all props
for (size_t j = 0; j < m_Props.size(); ++j)
{
@ -548,7 +548,7 @@ void CModel::ShowAmmoProp()
for (size_t i = 0; i < m_Props.size(); ++i)
if (m_Props[i].m_Point == m_AmmoPropPoint)
m_Props[i].m_Hidden = (i != m_AmmoLoadedProp);
// we only need to invalidate the selection box here if it is based on props and their visibilities
if (!m_CustomSelectionShape)
m_SelectionBoxValid = false;

View File

@ -88,5 +88,5 @@ void CModelAbstract::CalcSelectionBox()
// transform object-space axis-aligned bounds to world-space arbitrary-aligned box
objBounds.Transform(GetTransform(), m_SelectionBox);
}
}

View File

@ -75,7 +75,7 @@ CVector3D CModelDef::SkinNormal(const SModelVertex& vtx,
{
result += newPoseMatrices[vtx.m_Blend.m_Bone[i]].Rotate(vtx.m_Norm) * vtx.m_Blend.m_Weight[i];
}
// If there was more than one influence, the result is probably not going
// to be of unit length (since it's a weighted sum of several independent
// unit vectors), so we need to normalise it.
@ -155,7 +155,7 @@ void CModelDef::SkinPointsAndNormals_SSE(
col1 = _mm_load_ps(mtx._data + 4);
col2 = _mm_load_ps(mtx._data + 8);
col3 = _mm_load_ps(mtx._data + 12);
// Loads and computes vertex coordinates.
vec0 = _mm_load1_ps(&vtx.m_Coords.X); // v0 = [x, x, x, x]
vec0 = _mm_mul_ps(col0, vec0); // v0 = [_11*x, _21*x, _31*x, _41*x]
@ -210,7 +210,7 @@ void CModelDef::BlendBoneMatrices(
{
const SVertexBlend& blend = m_pBlends[i];
CMatrix3D& boneMatrix = boneMatrices[m_NumBones + 1 + i];
// Note: there is a special case of joint influence, in which the vertex
// is influenced by the bind-shape matrix instead of a particular bone,
// which we indicate by setting the bone ID to the total number of bones.
@ -264,7 +264,7 @@ CModelDef* CModelDef::Load(const VfsPath& filename, const VfsPath& name)
// read everything in from file
unpacker.Read(filename,"PSMD");
// check version
if (unpacker.GetVersion()<FILE_READ_VERSION) {
throw PSERROR_File_InvalidVersion();
@ -275,7 +275,7 @@ CModelDef* CModelDef::Load(const VfsPath& filename, const VfsPath& name)
// now unpack everything
mdef->m_NumVertices = unpacker.UnpackSize();
// versions prior to 4 only support 1 UV set, 4 and later store it here
if (unpacker.GetVersion() <= 3)
{
@ -287,12 +287,12 @@ CModelDef* CModelDef::Load(const VfsPath& filename, const VfsPath& name)
}
mdef->m_pVertices=new SModelVertex[mdef->m_NumVertices];
for (size_t i = 0; i < mdef->m_NumVertices; ++i)
{
unpacker.UnpackRaw(&mdef->m_pVertices[i].m_Coords, 12);
unpacker.UnpackRaw(&mdef->m_pVertices[i].m_Norm, 12);
for (size_t s = 0; s < mdef->m_NumUVsPerVertex; ++s)
{
float uv[2];
@ -300,14 +300,14 @@ CModelDef* CModelDef::Load(const VfsPath& filename, const VfsPath& name)
mdef->m_pVertices[i].m_UVs.push_back(uv[0]);
mdef->m_pVertices[i].m_UVs.push_back(uv[1]);
}
unpacker.UnpackRaw(&mdef->m_pVertices[i].m_Blend, sizeof(SVertexBlend));
}
mdef->m_NumFaces = unpacker.UnpackSize();
mdef->m_pFaces=new SModelFace[mdef->m_NumFaces];
unpacker.UnpackRaw(mdef->m_pFaces,sizeof(SModelFace)*mdef->m_NumFaces);
mdef->m_NumBones = unpacker.UnpackSize();
if (mdef->m_NumBones)
{
@ -432,7 +432,7 @@ void CModelDef::Save(const VfsPath& filename, const CModelDef* mdef)
const size_t numFaces = mdef->GetNumFaces();
packer.PackSize(numFaces);
packer.PackRaw(mdef->GetFaces(), sizeof(SModelFace) * numFaces);
const size_t numBones = mdef->m_NumBones;
packer.PackSize(numBones);
if (numBones)
@ -447,7 +447,7 @@ void CModelDef::Save(const VfsPath& filename, const CModelDef* mdef)
packer.PackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X, sizeof(mdef->m_PropPoints[i].m_Rotation));
packer.PackRaw(&mdef->m_PropPoints[i].m_BoneIndex, sizeof(mdef->m_PropPoints[i].m_BoneIndex));
}
// flush everything out to file
packer.Write(filename);
}
@ -465,9 +465,9 @@ void CModelDef::SetRenderData(const void* key, CModelDefRPrivate* data)
CModelDefRPrivate* CModelDef::GetRenderData(const void* key) const
{
RenderDataMap::const_iterator it = m_RenderData.find(key);
if (it != m_RenderData.end())
return it->second;
return 0;
}

View File

@ -115,7 +115,7 @@ void CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari
XERO_ITER_EL(option, textures_element)
{
ENSURE(textures_element.GetNodeName() == el_texture);
Samp samp;
XERO_ITER_ATTR(textures_element, se)
{
@ -458,7 +458,7 @@ const CObjectBase::Variation CObjectBase::BuildVariation(const std::vector<u8>&
// and then insert the new ones:
for (std::vector<CObjectBase::Anim>::iterator it = var.m_Anims.begin(); it != var.m_Anims.end(); ++it)
variation.anims.insert(make_pair(it->m_AnimName, *it));
// Same for samplers, though perhaps not strictly necessary:
for (std::vector<CObjectBase::Samp>::iterator it = var.m_Samplers.begin(); it != var.m_Samplers.end(); ++it)
variation.samplers.erase(it->m_SamplerName.string());

View File

@ -63,7 +63,7 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
for (std::multimap<CStr, CObjectBase::Samp>::iterator it = variation.samplers.begin(); it != variation.samplers.end(); ++it)
m_Samplers.push_back(it->second);
m_ModelName = variation.model;
if (! variation.color.empty())
@ -80,7 +80,7 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
if (variation.decal.m_SizeX && variation.decal.m_SizeZ)
{
CMaterial material = g_Renderer.GetMaterialManager().LoadMaterial(m_Base->m_Material);
for (const CObjectBase::Samp& samp : m_Samplers)
{
CTextureProperties textureProps(samp.m_SamplerFile);
@ -128,10 +128,10 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
model->SetMaterial(g_Renderer.GetMaterialManager().LoadMaterial(m_Base->m_Material));
model->GetMaterial().AddStaticUniform("objectColor", CVector4D(m_Color.r, m_Color.g, m_Color.b, m_Color.a));
model->InitModel(modeldef);
if (m_Samplers.empty())
LOGERROR("Actor '%s' has no textures.", utf8_from_wstring(m_Base->m_ShortName));
for (const CObjectBase::Samp& samp : m_Samplers)
{
CTextureProperties textureProps(samp.m_SamplerFile);
@ -150,7 +150,7 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
[&](const CObjectBase::Samp& sampler) { return sampler.m_SamplerName == requSampName; }) == m_Samplers.end())
LOGERROR("Actor %s: required texture sampler %s not found (material %s)", utf8_from_wstring(m_Base->m_ShortName), requSampName.string().c_str(), m_Base->m_Material.string8().c_str());
}
// calculate initial object space bounds, based on vertex positions
model->CalcStaticObjectBounds();

View File

@ -181,7 +181,7 @@ void CParticleEmitter::Bind(const CShaderProgramPtr& shader)
CLOSTexture& los = g_Renderer.GetScene().GetLOSTexture();
shader->BindTexture(str_losTex, los.GetTextureSmooth());
shader->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
shader->Uniform(str_sunColor, lightEnv.m_SunColor);
shader->Uniform(str_fogColor, lightEnv.m_FogColor);

View File

@ -36,7 +36,7 @@ CPatch::CPatch()
// CPatch destructor
CPatch::~CPatch()
{
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -264,7 +264,7 @@ void CShaderConditionalDefines::Add(const char* defname, const char* defvalue, i
cd.m_DefValue = CStrIntern(defvalue);
cd.m_CondArgs = args;
cd.m_CondType = type;
m_Defines.push_back(cd);
}

View File

@ -252,7 +252,7 @@ bool CShaderManager::NewProgram(const char* name, const CShaderDefines& baseDefi
#endif
else if (t == "samplerCube")
type = GL_TEXTURE_CUBE_MAP;
fragmentUniforms[CStrIntern(Attrs.GetNamedItem(at_name))] =
std::make_pair(Attrs.GetNamedItem(at_loc).ToInt(), type);
}
@ -496,7 +496,7 @@ bool CShaderManager::NewEffect(const char* name, const CShaderDefines& baseDefin
});
CShaderDefines techDefines = baseDefines;
XERO_ITER_EL(usableTechs[0].first, Child)
{
if (Child.GetNodeName() == el_define)

View File

@ -244,7 +244,7 @@ private:
GLuint m_FragmentProgram;
std::map<CStrIntern, int> m_VertexIndexes;
// pair contains <index, gltype>
std::map<CStrIntern, frag_index_pair_t> m_FragmentIndexes;
};
@ -360,7 +360,7 @@ public:
LOGMESSAGE("Info when linking program '%s'+'%s':\n%s", m_VertexFile.string8(), m_FragmentFile.string8(), infolog);
else
LOGERROR("Failed to link program '%s'+'%s':\n%s", m_VertexFile.string8(), m_FragmentFile.string8(), infolog);
delete[] infolog;
}

View File

@ -677,7 +677,7 @@ public:
between the texture and {1,1,1}) giving
A0/2 + 0.5
and use that as Arg0.
So L = 4*(A0/2 * (Arg1-.5))
= 2 (Rx+Gy+Bz) (where Arg1 = {x+0.5, y+0.5, z+0.5})
= 2x R + 2y G + 2z B
@ -809,7 +809,7 @@ protected:
ID_playerColor,
ID_losTransform
};
bool m_IgnoreLos;
public:
@ -837,7 +837,7 @@ public:
if (id.second == ID_transform)
glLoadMatrixf(&v._11);
}
virtual void Uniform(Binding id, float v0, float v1, float UNUSED(v2), float UNUSED(v3))
{
if (id.second == ID_losTransform)
@ -857,9 +857,9 @@ public:
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
// -----------------------------------------------------------------------------
pglActiveTextureARB(GL_TEXTURE3);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@ -879,7 +879,7 @@ public:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
// Overridden implementation of Uniform() sets GL_OBJECT_PLANE values
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
@ -891,7 +891,7 @@ public:
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
// -----------------------------------------------------------------------------
BindClientStates();
@ -900,13 +900,13 @@ public:
virtual void Unbind()
{
UnbindClientStates();
pglActiveTextureARB(GL_TEXTURE3);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
pglActiveTextureARB(GL_TEXTURE0);
glMatrixMode(GL_PROJECTION);

View File

@ -91,7 +91,7 @@ CSkeletonAnimDef* CSkeletonAnimDef::Load(const VfsPath& filename)
{
CFileUnpacker unpacker;
unpacker.Read(filename,"PSSA");
// check version
if (unpacker.GetVersion()<FILE_READ_VERSION) {
throw PSERROR_File_InvalidVersion();

View File

@ -331,7 +331,7 @@ fixed CTerrain::GetSlopeFixed(ssize_t i, ssize_t j) const
u16 h01 = m_Heightmap[(j+1)*m_MapSize + i];
u16 h10 = m_Heightmap[j*m_MapSize + (i+1)];
u16 h11 = m_Heightmap[(j+1)*m_MapSize + (i+1)];
// Difference of highest point from lowest point
u16 delta = std::max(std::max(h00, h01), std::max(h10, h11)) -
std::min(std::min(h00, h01), std::min(h10, h11));

View File

@ -40,7 +40,7 @@ CTerrainProperties::CTerrainProperties(CTerrainPropertiesPtr parent):
m_MovementClass("default")
{
if (m_pParent)
m_Groups = m_pParent->m_Groups;
m_Groups = m_pParent->m_Groups;
}
CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& parent, const VfsPath& pathname)
@ -60,11 +60,11 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& p
rootName);
return CTerrainPropertiesPtr();
}
#define ELMT(x) int el_##x = XeroFile.GetElementID(#x)
ELMT(terrain);
#undef ELMT
// Ignore all non-terrain nodes, loading the first terrain node and
// returning it.
// Really, we only expect there to be one child and it to be of the right
@ -85,7 +85,7 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(const CTerrainPropertiesPtr& p
// Keep reading - typos shouldn't be showstoppers
}
}
return CTerrainPropertiesPtr();
}
@ -120,7 +120,7 @@ void CTerrainProperties::LoadXml(XMBElement node, CXeromyces *pFile, const VfsPa
CColor col;
if (!col.ParseString(attr.Value, 255))
continue;
// m_BaseColor is BGRA
u8 *baseColor = (u8*)&m_BaseColor;
baseColor[0] = (u8)(col.b*255);

View File

@ -43,7 +43,7 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
m_BaseColorValid(false)
{
ENSURE(properties);
CXeromyces XeroFile;
if (XeroFile.Load(g_VFS, path, "terrain_texture") != PSRETURN_OK)
{
@ -64,8 +64,8 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
AT(name);
#undef AT
#undef EL
XMBElement root = XeroFile.GetRoot();
if (root.GetNodeName() != el_terrain)
@ -73,13 +73,13 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
LOGERROR("Invalid terrain format (unrecognised root element '%s')", XeroFile.GetElementString(root.GetNodeName()).c_str());
return;
}
std::vector<std::pair<CStr, VfsPath> > samplers;
VfsPath alphamap("standard");
m_Tag = utf8_from_wstring(path.Basename().string());
XERO_ITER_EL(root, child)
{
int child_name = child.GetNodeName();
@ -89,7 +89,7 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
XERO_ITER_EL(child, textures_element)
{
ENSURE(textures_element.GetNodeName() == el_texture);
CStr name;
VfsPath path;
XERO_ITER_ATTR(textures_element, se)
@ -101,7 +101,7 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
}
samplers.emplace_back(name, path);
}
}
else if (child_name == el_material)
{
@ -124,8 +124,8 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
m_Tag = child.GetText();
}
}
for (size_t i = 0; i < samplers.size(); ++i)
{
CTextureProperties texture(samplers[i].second);
@ -155,7 +155,7 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
texAngle = m_pProperties->GetTextureAngle();
texSize = m_pProperties->GetTextureSize();
}
m_TextureMatrix.SetZero();
m_TextureMatrix._11 = cosf(texAngle) / texSize;
m_TextureMatrix._13 = -sinf(texAngle) / texSize;
@ -206,16 +206,16 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype)
std::wstring key = L"(alpha map composite" + amtype.string() + L")";
CTerrainTextureManager::TerrainAlphaMap::iterator it = g_TexMan.m_TerrainAlphas.find(amtype);
if (it != g_TexMan.m_TerrainAlphas.end())
{
m_TerrainAlpha = it;
return;
}
g_TexMan.m_TerrainAlphas[amtype] = TerrainAlpha();
it = g_TexMan.m_TerrainAlphas.find(amtype);
TerrainAlpha &result = it->second;
//
@ -224,7 +224,7 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype)
Handle textures[NUM_ALPHA_MAPS] = {0};
VfsPath path(L"art/textures/terrain/alphamaps");
path = path / amtype;
const wchar_t* fnames[NUM_ALPHA_MAPS] = {
L"blendcircle.png",
L"blendlshape.png",
@ -254,7 +254,7 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype)
{
g_TexMan.m_TerrainAlphas.erase(it);
LOGERROR("Failed to load alphamap: %s", amtype.string8());
VfsPath standard("standard");
if (path != standard)
{
@ -334,11 +334,11 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype)
// upload the composite texture
Tex t;
(void)t.wrap(total_w, total_h, 8, TEX_GREY, data, 0);
// uncomment the following to save a png of the generated texture
// in the public/ directory, for debugging
/*VfsPath filename("blendtex.png");
DynArray da;
RETURN_STATUS_IF_ERR(tex_encode(&t, filename.Extension(), &da));
@ -354,12 +354,12 @@ void CTerrainTextureEntry::LoadAlphaMaps(VfsPath &amtype)
}
(void)da_free(&da);*/
Handle hCompositeAlphaMap = ogl_tex_wrap(&t, g_VFS, key);
(void)ogl_tex_set_filter(hCompositeAlphaMap, GL_LINEAR);
(void)ogl_tex_set_wrap (hCompositeAlphaMap, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
ogl_tex_upload(hCompositeAlphaMap, GL_ALPHA, 0, 0);
result.m_hCompositeAlphaMap = hCompositeAlphaMap;
m_TerrainAlpha = it;
}

View File

@ -49,7 +49,7 @@ CTerrainTextureManager::CTerrainTextureManager()
CTerrainTextureManager::~CTerrainTextureManager()
{
UnloadTerrainTextures();
for (std::pair<const VfsPath, TerrainAlpha>& ta : m_TerrainAlphas)
{
ogl_tex_free(ta.second.m_hCompositeAlphaMap);

View File

@ -82,7 +82,7 @@ std::vector<STerritoryBoundary> CTerritoryBoundaryCalculator::ComputeBoundaries(
// If at some point we ever need to revert the winding order or external code needs to know about it explicitly, then we can
// do this by looking at a curvature value which we define to start at 0, and which is incremented by 1 for every CCW turn and
// decremented by 1 for every CW turn. Hence, a negative multiple of 4 means a CW winding order, and a positive one means CCW.
const int TERRITORY_DISCR_MASK = (ICmpTerritoryManager::TERRITORY_BLINKING_MASK | ICmpTerritoryManager::TERRITORY_PLAYER_MASK);
// Try to find an assigned tile

View File

@ -60,7 +60,7 @@ struct TPhash
struct TPequal_to
: std::binary_function<CTextureProperties, CTextureProperties, bool>,
std::binary_function<CTexturePtr, CTexturePtr, bool>
{
{
bool operator()(CTextureProperties const& a, CTextureProperties const& b) const
{
return a.m_Path == b.m_Path && a.m_Filter == b.m_Filter

View File

@ -115,7 +115,7 @@ void CUnit::ReloadObject()
// made might define some additional props that require a random variant choice). Also, FindObjectVariation
// expects the selectors passed to it to be complete.
// see http://trac.wildfiregames.com/ticket/979
// Use the entity ID as randomization seed (same as when the unit was first created)
std::set<CStr> remainingSelections = m_Object->m_Base->CalculateRandomRemainingSelections(m_Seed, selections);
if (!remainingSelections.empty())

View File

@ -139,7 +139,7 @@ std::wstring L10n::GetFallbackToAvailableDictLocale(const Locale& locale) const
return strcmp(locale.getLanguage(), l->getLanguage()) == 0
&& strcmp(locale.getCountry(), l->getCountry()) == 0;
};
if (strcmp(locale.getCountry(), "") != 0
&& std::find_if(availableLocales.begin(), availableLocales.end(), checkLangAndCountry) != availableLocales.end())
{
@ -156,7 +156,7 @@ std::wstring L10n::GetFallbackToAvailableDictLocale(const Locale& locale) const
stream << locale.getLanguage();
return stream.str();
}
return L"";
}
@ -181,7 +181,7 @@ void L10n::GetDictionaryLocale(const std::string& configLocaleString, Locale& ou
else
LOGWARNING("The configured locale is not valid or no translations are available. Falling back to another locale.");
}
Locale systemLocale = Locale::getDefault();
if (ValidateLocale(systemLocale))
outLocale = systemLocale;

View File

@ -521,7 +521,7 @@ template<class T> bool get_container_info(const T& t, size_t size, size_t el_siz
{
typedef typename T::iterator iterator;
typedef typename T::const_iterator const_iterator;
ENSURE(sizeof(T) == size);
ENSURE(sizeof(iterator) < DEBUG_STL_MAX_ITERATOR_SIZE);

View File

@ -47,7 +47,7 @@ bool HasEnergyPerfBias()
#if 1
// the documentation is unclear. until it improves, disable
// this, lest we provoke a GPF.
return false;
return false;
#else
if(x86_x64::Vendor() != x86_x64::VENDOR_INTEL)
return false;

View File

@ -342,7 +342,7 @@ static Status InitIdentifierString()
else if(model == 3 || model == 5)
strcpy_s(identifierString, ARRAY_SIZE(identifierString), "Intel Pentium II");
else if(model == 6)
strcpy_s(identifierString, ARRAY_SIZE(identifierString), "Intel Celeron");
strcpy_s(identifierString, ARRAY_SIZE(identifierString), "Intel Celeron");
else
strcpy_s(identifierString, ARRAY_SIZE(identifierString), "Intel Pentium III");
}

View File

@ -68,7 +68,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
wchar_t symbol[DEBUG_SYMBOL_CHARS];
int line;
int len;
if (debug_ResolveSymbol(bt[i], symbol, file, &line) == 0)
{
if (file[0])
@ -80,7 +80,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
{
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p)\n", bt[i]);
}
if (len < 0)
{
// MAX_OUT_CHARS exceeded, realistically this was caused by some
@ -89,7 +89,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
memcpy(&bufpos[MAX_OUT_CHARS-6], L"...\n", 5*sizeof(wchar_t));
len = MAX_OUT_CHARS;
}
bufpos += len;
}

View File

@ -176,7 +176,7 @@ Status dir_watch_Add(const OsPath& path, PDirWatch& dirWatch)
{
char resolved[PATH_MAX + 1];
// init already failed; don't try again or complain
// init already failed; don't try again or complain
if(initialized == -1)
return ERR::FAIL; // NOWARN

View File

@ -162,7 +162,7 @@ uintptr_t os_cpu_SetThreadAffinityMask(uintptr_t processorMask)
previousProcessorMask |= uintptr_t(1) << processor;
}
}
CPU_ZERO_S(setSize, set);
for(size_t processor = 0; processor < os_cpu_NumProcessors(); processor++)
{

View File

@ -90,7 +90,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
wchar_t symbol[DEBUG_SYMBOL_CHARS];
int line;
int len;
if (debug_ResolveSymbol(bt[i], symbol, file, &line) == 0)
{
if (file[0])
@ -102,7 +102,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
{
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p)\n", bt[i]);
}
if (len < 0)
{
// MAX_OUT_CHARS exceeded, realistically this was caused by some
@ -111,7 +111,7 @@ Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), co
memcpy(&bufpos[MAX_OUT_CHARS-6], L"...\n", 5*sizeof(wchar_t));
len = MAX_OUT_CHARS;
}
bufpos += len;
}

View File

@ -123,7 +123,7 @@ Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq)
{
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
*freq = (int)CGDisplayModeGetRefreshRate(currentMode);
// We're responsible for this
CGDisplayModeRelease(currentMode);
}

View File

@ -68,7 +68,7 @@ void udbg_launch_debugger()
// Child Process: exec() gdb (Debugger), set to attach to old fork
char buf[16];
snprintf(buf, 16, DEBUGGER_ARG_FORMAT, orgpid);
int ret=execlp(DEBUGGER_CMD, DEBUGGER_CMD, buf, NULL);
// In case of success, we should never get here anyway, though...
if (ret != 0)

View File

@ -67,18 +67,18 @@ Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq)
WARN_RETURN(ERR::FAIL);
int screen = XDefaultScreen(disp);
/* 2004-07-13
NOTE: The XDisplayWidth/Height functions don't actually return the current
display mode - they return the size of the root window. This means that
users with "Virtual Desktops" bigger than what their monitors/graphics
card can handle will have to set their 0AD screen resolution manually.
There's supposed to be an X extension that can give you the actual display
mode, probably including refresh rate info etc, but it's not worth
researching and implementing that at this stage.
*/
if(xres)
*xres = XDisplayWidth(disp, screen);
if(yres)
@ -99,10 +99,10 @@ Status GetMonitorSize(int& width_mm, int& height_mm)
WARN_RETURN(ERR::FAIL);
int screen = XDefaultScreen(disp);
width_mm = XDisplayWidthMM(disp, screen);
height_mm = XDisplayHeightMM(disp, screen);
XCloseDisplay(disp);
return INFO::OK;
}
@ -190,12 +190,12 @@ wchar_t *sys_clipboard_get()
Atom pty=XInternAtom(disp, "SelectionPropertyTemp", False);
XConvertSelection(disp, selSource, XA_STRING, pty, selOwner, CurrentTime);
XFlush(disp);
Atom type;
int format=0, result=0;
unsigned long len=0, bytes_left=0, dummy=0;
u8 *data=NULL;
// Get the length of the property and some attributes
// bytes_left will contain the length of the selection
result = XGetWindowProperty (disp, selOwner, pty,
@ -215,12 +215,12 @@ wchar_t *sys_clipboard_get()
pty, 0, bytes_left, 0,
AnyPropertyType, &type, &format,
&len, &dummy, &data);
if(result == Success)
{
debug_printf("clipboard_get: XGetWindowProperty succeeded, returning data\n");
debug_printf("clipboard_get: data was: \"%s\", type was %lu, XA_STRING atom is %lu\n", (char *)data, type, XA_STRING);
if(type == XA_STRING) //Latin-1: Just copy into low byte of wchar_t
{
wchar_t *ret=(wchar_t *)malloc((bytes_left+1)*sizeof(wchar_t));
@ -237,7 +237,7 @@ wchar_t *sys_clipboard_get()
}
}
}
return NULL;
}
@ -286,12 +286,12 @@ int clipboard_filter(void* UNUSED(userdata), SDL_Event* event)
{
size_t size = wcslen(selection_data);
u8* buf = (u8*)alloca(size);
for(size_t i = 0; i < size; i++)
{
buf[i] = selection_data[i] < 0x100 ? selection_data[i] : '?';
}
XChangeProperty(g_SDL_Display, req->requestor, req->property,
sevent.xselection.target, 8, PropModeReplace,
buf, size);
@ -359,7 +359,7 @@ Status sys_clipboard_set(const wchar_t *str)
free(selection_data);
selection_data = NULL;
}
selection_size = (wcslen(str)+1)*sizeof(wchar_t);
selection_data = (wchar_t *)malloc(selection_size);
wcscpy(selection_data, str);

View File

@ -274,7 +274,7 @@ static void StartDriver(const OsPath& driverPathname)
hService = 0;
UninstallDriver();
}
#endif
#endif
// create service (note: this just enters the service into SCM's DB;
// no error is raised if the driver binary doesn't exist etc.)

View File

@ -313,7 +313,7 @@ Status wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, CONTEXT& cont
sym_init();
STACKFRAME64 sf = PopulateStackFrame(context);
wchar_t func[DEBUG_SYMBOL_CHARS];
Status ret = ERR::SYM_NO_STACK_FRAMES_FOUND;

View File

@ -110,7 +110,7 @@ void wdll_ver_Append(const OsPath& pathname, VersionList& list)
if(!list.empty())
list += L", ";
list += moduleName.Filename().string();
list += L" (";
list += versionString;

View File

@ -62,7 +62,7 @@ static inline WDIR* wdir_alloc()
{
if(cpu_CAS(&wdir_in_use, 0, 1)) // gained ownership
return &wdir_storage;
// already in use (rare) - allocate from heap
return new WDIR;
}

View File

@ -507,11 +507,11 @@ static std::wstring parse_proxy(const std::wstring& input)
std::vector<std::wstring> parts;
split(parts, input, boost::algorithm::is_any_of("; \t\r\n"), boost::algorithm::token_compress_on);
for(size_t i = 0; i < parts.size(); ++i)
if(boost::algorithm::starts_with(parts[i], "http="))
return parts[i].substr(5);
// If we got this far, proxies were only set for non-HTTP protocols
return L"";
}

View File

@ -70,11 +70,11 @@ void* rtl_AllocateAligned(size_t size, size_t align)
// least sizeof(void*) alignment.
if (align < 2*sizeof(void*))
align = 2*sizeof(void*);
void* const malloc_ptr = malloc(size + align);
if (!malloc_ptr)
return NULL;
// Round malloc_ptr up to the next aligned address, leaving some unused
// space before the pointer we'll return. The minimum alignment above
// ensures we'll have at least sizeof(void*) extra space.

View File

@ -705,7 +705,7 @@ size_t Tex::img_size() const
size_t tex_hdr_size(const VfsPath& filename)
{
const ITexCodec* c;
const OsPath extension = filename.Extension();
WARN_RETURN_STATUS_IF_ERR(tex_codec_for_filename(extension, &c));
return c->hdr_size(0);

View File

@ -68,7 +68,7 @@ Status tex_codec_for_header(const u8* file, size_t file_size, const ITexCodec**
// we guarantee at least 4 bytes for is_hdr to look at
if(file_size < 4)
WARN_RETURN(ERR::TEX_INCOMPLETE_HEADER);
for(int i = 0; i < codecs_len; ++i)
{
// we found it

View File

@ -127,7 +127,7 @@ static Status png_decode_impl(MemoryStream* stream, png_structp png_ptr, png_inf
png_uint_32 w, h;
int bit_depth, color_type, interlace_type;
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, &interlace_type, 0, 0);
// (The following is based on GdkPixbuf's PNG image loader)
// Convert the following images to 8-bit RGB/RGBA:
@ -152,7 +152,7 @@ static Status png_decode_impl(MemoryStream* stream, png_structp png_ptr, png_inf
// Update info after transformations
png_read_update_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, &interlace_type, 0, 0);
// make sure format is acceptable:
@ -166,7 +166,7 @@ static Status png_decode_impl(MemoryStream* stream, png_structp png_ptr, png_inf
WARN_RETURN(ERR::TEX_NOT_8BIT_PRECISION);
if (!(color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA || color_type == PNG_COLOR_TYPE_GRAY))
WARN_RETURN(ERR::TEX_INVALID_COLOR_TYPE);
const int channels = png_get_channels(png_ptr, info_ptr);
if (!(channels == 3 || channels == 4 || channels == 1))
WARN_RETURN(ERR::TEX_FMT_INVALID);
@ -298,7 +298,7 @@ TIMER_ACCRUE(tc_png_decode);
Status ret = png_decode_impl(&stream, png_ptr, info_ptr, t);
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
return ret;
}

View File

@ -185,7 +185,7 @@ JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate)
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
JSAutoRequest rq(cx);
JS::RootedValue playerList(cx);
g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList);
@ -254,7 +254,7 @@ JS::Value JSI_Lobby::LobbyGuiPollMessage(ScriptInterface::CxPrivate* pCxPrivate)
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
JSAutoRequest rq(cx);
JS::RootedValue poll(cx);
g_XmppClient->GuiPollMessage(*(pCxPrivate->pScriptInterface), &poll);
@ -265,7 +265,7 @@ void JSI_Lobby::LobbySendMessage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
{
if (!g_XmppClient)
return;
g_XmppClient->SendMUCMessage(utf8_from_wstring(message));
}

View File

@ -158,7 +158,7 @@ static void PumpEvents()
{
JSContext* cx = g_GUI->GetScriptInterface()->GetContext();
JSAutoRequest rq(cx);
PROFILE3("dispatch events");
SDL_Event_ ev;

View File

@ -87,7 +87,7 @@ struct SliceOpNewVertexInfo
size_t edgeIdx1, edgeIdx2;
/// Index of newly introduced vertex in resulting brush
size_t resIdx;
/**
* Index into SliceOpInfo.nvInfo; hold the indices of this new vertex's direct neighbours in the slicing plane face,
* with no consistent winding direction around the face for either field (e.g., the neighb1 of X can point back to
@ -107,10 +107,10 @@ struct SliceOpInfo
* Same size as m_Vertices of the brush getting sliced.
*/
std::vector<SliceOpVertexInfo> ovInfo;
/// Holds information about newly inserted vertices during a slice operation.
std::vector<SliceOpNewVertexInfo> nvInfo;
/**
* Indices into nvInfo; during the execution of the slicing algorithm, holds the previously inserted new vertex on
* one of the edges of the face that's currently being evaluated for slice points, or NO_VERTEX if no such vertex
@ -144,7 +144,7 @@ size_t CBrush::Helper::SliceNewVertex(SliceOpInfo& sliceOp, size_t edgeIdx1, siz
// no previously inserted new vertex found on this edge; insert a new one
SliceOpNewVertexInfo nvi;
CVector3D newPos;
// interpolate between the two vertices based on their distance from the plane
float inv = 1.0 / (sliceOp.ovInfo[edgeIdx1].planeDist - sliceOp.ovInfo[edgeIdx2].planeDist);
newPos = sliceOp.original->m_Vertices[edgeIdx2] * ( sliceOp.ovInfo[edgeIdx1].planeDist * inv) +
@ -296,7 +296,7 @@ void CBrush::Slice(const CPlane& plane, CBrush& result) const
{
// push the starting vertex
result.m_Faces.push_back(sliceOp.nvInfo[0].resIdx);
// At this point, there is no consistent winding order in the neighbX fields, so at each vertex we need to figure
// out whether neighb1 or neighb2 points 'onwards' along the face, according to an initially chosen winding direction.
// (or, equivalently, which one points back to the one we were just at). At each vertex, we then set neighb1 to be the

View File

@ -62,7 +62,7 @@ void CMatrix3D::SetXRotation (float angle)
{
const float Cos = cosf (angle);
const float Sin = sinf (angle);
_11=1.0f; _12=0.0f; _13=0.0f; _14=0.0f;
_21=0.0f; _22=Cos; _23=-Sin; _24=0.0f;
_31=0.0f; _32=Sin; _33=Cos; _34=0.0f;
@ -165,7 +165,7 @@ void CMatrix3D::SetTranslation (float x, float y, float z)
void CMatrix3D::SetTranslation(const CVector3D& vector)
{
SetTranslation(vector.X, vector.Y, vector.Z);
SetTranslation(vector.X, vector.Y, vector.Z);
}
//Applies a translation to the matrix
@ -279,7 +279,7 @@ void CMatrix3D::GetInverse(CMatrix3D& dst) const
float tmp[12]; // temp array for pairs
float src[16]; // array of transpose source matrix
float det; // determinant
// transpose matrix
for (int i = 0; i < 4; ++i) {
src[i] = _data[i*4];
@ -301,7 +301,7 @@ void CMatrix3D::GetInverse(CMatrix3D& dst) const
tmp[9] = src[10] * src[12];
tmp[10] = src[8] * src[13];
tmp[11] = src[9] * src[12];
// calculate first 8 elements (cofactors)
dst._data[0] = (tmp[0]-tmp[1])*src[5] + (tmp[3]-tmp[2])*src[6] + (tmp[4]-tmp[5])*src[7];
dst._data[1] = (tmp[1]-tmp[0])*src[4] + (tmp[6]-tmp[7])*src[6] + (tmp[9]-tmp[8])*src[7];
@ -311,7 +311,7 @@ void CMatrix3D::GetInverse(CMatrix3D& dst) const
dst._data[5] = (tmp[0]-tmp[1])*src[0] + (tmp[7]-tmp[6])*src[2] + (tmp[8]-tmp[9])*src[3];
dst._data[6] = (tmp[3]-tmp[2])*src[0] + (tmp[6]-tmp[7])*src[1] + (tmp[11]-tmp[10])*src[3];
dst._data[7] = (tmp[4]-tmp[5])*src[0] + (tmp[9]-tmp[8])*src[1] + (tmp[10]-tmp[11])*src[2];
// calculate pairs for second 8 elements (cofactors)
tmp[0] = src[2]*src[7];
tmp[1] = src[3]*src[6];

View File

@ -73,24 +73,24 @@ float Noise2D::operator()(float x, float y)
{
x *= freq;
y *= freq;
int ix = (int)floor(x);
int iy = (int)floor(y);
float fx = x - ix;
float fy = y - iy;
ix %= freq; if(ix<0) ix += freq;
iy %= freq; if(iy<0) iy += freq;
int ix1 = (ix+1) % freq;
int iy1 = (iy+1) % freq;
float s = grads[ix][iy].Dot(CVector2D(fx, fy));
float t = grads[ix1][iy].Dot(CVector2D(fx-1, fy));
float u = grads[ix][iy1].Dot(CVector2D(fx, fy-1));
float v = grads[ix1][iy1].Dot(CVector2D(fx-1, fy-1));
float ex = easeCurve(fx);
float ey = easeCurve(fy);
float a = s + ex*(t-s);
@ -139,45 +139,45 @@ float Noise3D::operator()(float x, float y, float z)
x *= freq;
y *= freq;
z *= vfreq;
int ix = (int)floor(x);
int iy = (int)floor(y);
int iz = (int)floor(z);
float fx = x - ix;
float fy = y - iy;
float fz = z - iz;
ix %= freq; if(ix<0) ix += freq;
iy %= freq; if(iy<0) iy += freq;
iz %= vfreq; if(iz<0) iz += vfreq;
int ix1 = (ix+1) % freq;
int iy1 = (iy+1) % freq;
int iz1 = (iz+1) % vfreq;
float s0 = grads[ix][iy][iz].Dot(CVector3D(fx, fy, fz));
float t0 = grads[ix1][iy][iz].Dot(CVector3D(fx-1, fy, fz));
float u0 = grads[ix][iy1][iz].Dot(CVector3D(fx, fy-1, fz));
float v0 = grads[ix1][iy1][iz].Dot(CVector3D(fx-1, fy-1, fz));
float s1 = grads[ix][iy][iz1].Dot(CVector3D(fx, fy, fz-1));
float t1 = grads[ix1][iy][iz1].Dot(CVector3D(fx-1, fy, fz-1));
float u1 = grads[ix][iy1][iz1].Dot(CVector3D(fx, fy-1, fz-1));
float v1 = grads[ix1][iy1][iz1].Dot(CVector3D(fx-1, fy-1, fz-1));
float ex = easeCurve(fx);
float ey = easeCurve(fy);
float ez = easeCurve(fz);
float a0 = s0 + ex*(t0-s0);
float b0 = u0 + ex*(v0-u0);
float c0 = a0 + ey*(b0-a0);
float a1 = s1 + ex*(t1-s1);
float b1 = u1 + ex*(v1-u1);
float c1 = a1 + ey*(b1-a1);
return (c0 + ez*(c1-c0)) * .5 + .5;
}

View File

@ -164,10 +164,10 @@ void CQuaternion::ToMatrix(CMatrix3D& result) const
xx = m_V.X * m_V.X * 2.f;
xy = m_V.X * m_V.Y * 2.f;
xz = m_V.X * m_V.Z * 2.f;
yy = m_V.Y * m_V.Y * 2.f;
yz = m_V.Y * m_V.Z * 2.f;
zz = m_V.Z * m_V.Z * 2.f;
wx = m_W * m_V.X * 2.f;
@ -199,7 +199,7 @@ void CQuaternion::Slerp(const CQuaternion& from, const CQuaternion& to, float ra
{
float to1[4];
float omega, cosom, sinom, scale0, scale1;
// calc cosine
cosom = from.Dot(to);
@ -301,7 +301,7 @@ CVector3D CQuaternion::Rotate(const CVector3D& vec) const
{
// v' = q * v * q^-1
// (where v is the quat. with w=0, xyz=vec)
return (*this * CQuaternion(vec.X, vec.Y, vec.Z, 0.f) * GetInverse()).m_V;
}

View File

@ -39,9 +39,9 @@ int CVector3D::operator ! () const
if (X != 0.0f ||
Y != 0.0f ||
Z != 0.0f)
return 0;
return 1;
}

View File

@ -125,11 +125,11 @@ void CArchiveBuilder::Build(const OsPath& archive, bool compress)
writer->AddFile(realPath, path);
continue;
}
VfsPath cachedPath;
debug_printf("Converting model %s\n", realPath.string8().c_str());
bool ok = colladaManager.GenerateCachedFile(path, type, cachedPath);
// The DAE might fail to convert for whatever reason, and in that case
// it can't be used in the game, so we just exclude it
// (alternatively we could throw release blocking errors on useless files)

View File

@ -484,7 +484,7 @@ void CConsole::InsertMessage(const std::string& message)
std::wstring newline(L"\n");
size_t oldNewline=0;
size_t distance;
//make sure everything has been initialized
if ( m_charsPerPage != 0 )
{
@ -547,7 +547,7 @@ void CConsole::ProcessBuffer(const wchar_t* szLine)
shared_ptr<ScriptInterface> pScriptInterface = g_GUI->GetActiveGUI()->GetScriptInterface();
JSContext* cx = pScriptInterface->GetContext();
JSAutoRequest rq(cx);
if (szLine == NULL) return;
if (wcslen(szLine) <= 0) return;
@ -558,7 +558,7 @@ void CConsole::ProcessBuffer(const wchar_t* szLine)
// a crash it's a useful record.
// Process it as JavaScript
JS::RootedValue rval(cx);
pScriptInterface->Eval(szLine, &rval);
if (!rval.isUndefined())

View File

@ -96,7 +96,7 @@ void CLogger::Init()
m_NumberOfMessages = 0;
m_NumberOfErrors = 0;
m_NumberOfWarnings = 0;
*m_MainLog << html_header0 << engine_version << ") Main log" << html_header1;
*m_InterestingLog << html_header0 << engine_version << ") Main log (warnings and errors only)" << html_header1;
}
@ -117,7 +117,7 @@ CLogger::~CLogger()
*m_MainLog << "<p>Engine exited successfully on " << currentDate;
*m_MainLog << " at " << currentTime << buffer << "</p>\n";
*m_InterestingLog << "<p>Engine exited successfully on " << currentDate;
*m_InterestingLog << " at " << currentTime << buffer << "</p>\n";
@ -148,7 +148,7 @@ void CLogger::WriteMessage(const char* message, bool doRender = false)
*m_MainLog << "<p>" << cmessage << "</p>\n";
m_MainLog->flush();
if (doRender)
{
if (g_Console) g_Console->InsertMessage(std::string("INFO: ") + message);

View File

@ -305,7 +305,7 @@ void CStr::Remove(const CStr& Str)
while (FoundAt != npos)
{
FoundAt = find(Str, 0);
if (FoundAt != npos)
erase(FoundAt, Str.length());
}
@ -315,7 +315,7 @@ void CStr::Remove(const CStr& Str)
void CStr::Replace(const CStr& ToReplace, const CStr& ReplaceWith)
{
size_t Pos = 0;
while (Pos != npos)
{
Pos = find(ToReplace, Pos);
@ -358,7 +358,7 @@ std::string CStr::EscapeToPrintableASCII() const
CStr CStr::Trim(PS_TRIM_MODE Mode) const
{
size_t Left = 0, Right = 0;
switch (Mode)
{
case PS_TRIM_LEFT:
@ -367,7 +367,7 @@ CStr CStr::Trim(PS_TRIM_MODE Mode) const
if (_istspace((*this)[Left]) == false)
break; // end found, trim 0 to Left-1 inclusive
} break;
case PS_TRIM_RIGHT:
{
Right = length();
@ -375,7 +375,7 @@ CStr CStr::Trim(PS_TRIM_MODE Mode) const
if (_istspace((*this)[Right]) == false)
break; // end found, trim len-1 to Right+1 inclusive
} break;
case PS_TRIM_BOTH:
{
for (Left = 0; Left < length(); Left++)
@ -402,7 +402,7 @@ CStr CStr::Pad(PS_TRIM_MODE Mode, size_t Length) const
if (Length <= length())
return *this;
// From here: Length-length() >= 1
switch (Mode)

View File

@ -206,7 +206,7 @@ void CGame::RegisterInit(const JS::HandleValue attribs, const std::string& saved
ScriptInterface& scriptInterface = m_Simulation2->GetScriptInterface();
JSContext* cx = scriptInterface.GetContext();
JSAutoRequest rq(cx);
m_InitialSavedState = savedState;
m_IsSavedGame = !savedState.empty();
@ -292,7 +292,7 @@ PSRETURN CGame::ReallyStartGame()
{
JSContext* cx = m_Simulation2->GetScriptInterface().GetContext();
JSAutoRequest rq(cx);
// Call the script function InitGame only for new games, not saved games
if (!m_IsSavedGame)
{
@ -314,7 +314,7 @@ PSRETURN CGame::ReallyStartGame()
Interpolate(0, 0);
m_GameStarted=true;
// Render a frame to begin loading assets
if (CRenderer::IsInitialised())
Render();
@ -384,7 +384,7 @@ void CGame::Update(const double deltaRealTime, bool doInterpolate)
return;
const double deltaSimTime = deltaRealTime * m_SimRate;
if (deltaSimTime)
{
// To avoid confusing the profiler, we need to trigger the new turn

View File

@ -74,7 +74,7 @@ void ConvertCaches(ScriptInterface& scriptInterface, x86_x64::IdxCache idxCache,
{
JSContext* cx = scriptInterface.GetContext();
JSAutoRequest rq(cx);
scriptInterface.Eval("[]", ret);
for (size_t idxLevel = 0; idxLevel < x86_x64::Cache::maxLevels; ++idxLevel)
{
@ -97,7 +97,7 @@ void ConvertTLBs(ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
{
JSContext* cx = scriptInterface.GetContext();
JSAutoRequest rq(cx);
scriptInterface.Eval("[]", ret);
for(size_t i = 0; ; i++)
{

View File

@ -124,7 +124,7 @@ void LoadHotkeys()
for (const SKey& k : hotkey.requires)
if (!k.negated)
allNegated = false;
if (allNegated)
g_HotkeyStatus[hotkey.name] = true;
}

View File

@ -59,11 +59,11 @@ public:
virtual CStr GetTitle();
virtual size_t GetNumberRows();
virtual const std::vector<ProfileColumn>& GetColumns();
virtual CStr GetCellText(size_t row, size_t col);
virtual AbstractProfileTable* GetChild(size_t row);
virtual bool IsHighlightRow(size_t row);
private:
/**
* struct ColumnDescription: The only purpose of this helper structure
@ -73,7 +73,7 @@ private:
struct ColumnDescription
{
std::vector<ProfileColumn> columns;
ColumnDescription()
{
columns.push_back(ProfileColumn("Name", 230));
@ -85,10 +85,10 @@ private:
columns.push_back(ProfileColumn("mallocs/turn", 80));
}
};
/// The node represented by this table
CProfileNode* node;
/// Columns description (shared by all instances)
static ColumnDescription columnDescription;
};
@ -139,7 +139,7 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col)
size_t nrchildren = node->GetChildren()->size();
size_t nrscriptchildren = node->GetScriptChildren()->size();
char buf[256] = "?";
if (row < nrchildren)
child = (*node->GetChildren())[row];
else if (row < nrchildren + nrscriptchildren)
@ -155,7 +155,7 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col)
return "";
else if (col == 4)
return "";
double unlogged_time_frame = node->GetFrameTime();
double unlogged_time_turn = node->GetTurnTime();
double unlogged_mallocs_frame = node->GetFrameMallocs();
@ -176,7 +176,7 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col)
unlogged_mallocs_frame -= (*it)->GetFrameMallocs();
unlogged_mallocs_turn -= (*it)->GetTurnMallocs();
}
// The root node can't easily count per-turn values (since Turn isn't called until
// halfway though a frame), so just reset them the zero to prevent weird displays
if (!node->GetParent())
@ -193,16 +193,16 @@ CStr CProfileNodeTable::GetCellText(size_t row, size_t col)
sprintf_s(buf, ARRAY_SIZE(buf), "%.3f", unlogged_time_turn * 1000.f);
else if (col == 6)
sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", unlogged_mallocs_turn);
return CStr(buf);
}
switch(col)
{
default:
case 0:
return child->GetName();
case 1:
sprintf_s(buf, ARRAY_SIZE(buf), "%.1f", child->GetFrameCalls());
break;
@ -231,17 +231,17 @@ AbstractProfileTable* CProfileNodeTable::GetChild(size_t row)
CProfileNode* child;
size_t nrchildren = node->GetChildren()->size();
size_t nrscriptchildren = node->GetScriptChildren()->size();
if (row < nrchildren)
child = (*node->GetChildren())[row];
else if (row < nrchildren + nrscriptchildren)
child = (*node->GetScriptChildren())[row - nrchildren];
else
return 0;
if (child->CanExpand())
return child->display_table;
return 0;
}
@ -250,7 +250,7 @@ bool CProfileNodeTable::IsHighlightRow(size_t row)
{
size_t nrchildren = node->GetChildren()->size();
size_t nrscriptchildren = node->GetScriptChildren()->size();
return (row >= nrchildren && row < (nrchildren + nrscriptchildren));
}
@ -275,10 +275,10 @@ CProfileNode::~CProfileNode()
{
profile_iterator it;
for( it = children.begin(); it != children.end(); ++it )
delete( *it );
delete( *it );
for( it = script_children.begin(); it != script_children.end(); ++it )
delete( *it );
delete display_table;
}
@ -346,7 +346,7 @@ CProfileNode* CProfileNode::GetChild( const char* childName )
for( it = children.begin(); it != children.end(); ++it )
if( (*it)->name == childName )
return( *it );
CProfileNode* newNode = new CProfileNode( childName, this );
children.push_back( newNode );
return( newNode );
@ -358,7 +358,7 @@ CProfileNode* CProfileNode::GetScriptChild( const char* childName )
for( it = script_children.begin(); it != script_children.end(); ++it )
if( (*it)->name == childName )
return( *it );
CProfileNode* newNode = new CProfileNode( childName, this );
script_children.push_back( newNode );
return( newNode );
@ -402,7 +402,7 @@ void CProfileNode::Frame()
calls_frame_current = 0;
time_frame_current = 0.0;
mallocs_frame_current = 0;
profile_iterator it;
for (it = children.begin(); it != children.end(); ++it)
(*it)->Frame();

View File

@ -259,7 +259,7 @@ void CProfileViewer::RenderProfile()
if (col > 0) // right-align all but the first column
x += columns[col].width - w;
textRenderer.Put(x, 0.0f, text.c_str());
colX += columns[col].width;
}
@ -503,13 +503,13 @@ namespace
{
JSContext* cx = m_ScriptInterface.GetContext();
JSAutoRequest rq(cx);
JS::RootedValue t(cx);
JS::RootedValue rows(cx, DumpRows(table));
m_ScriptInterface.Eval(L"({})", &t);
m_ScriptInterface.SetProperty(t, "cols", DumpCols(table));
m_ScriptInterface.SetProperty(t, "data", rows);
m_ScriptInterface.SetProperty(m_Root, table->GetTitle().c_str(), t);
}
@ -529,7 +529,7 @@ namespace
{
JSContext* cx = m_ScriptInterface.GetContext();
JSAutoRequest rq(cx);
JS::RootedValue data(cx);
m_ScriptInterface.Eval("({})", &data);
@ -604,7 +604,7 @@ JS::Value CProfileViewer::SaveToJS(ScriptInterface& scriptInterface)
{
JSContext* cx = scriptInterface.GetContext();
JSAutoRequest rq(cx);
JS::RootedValue root(cx);
scriptInterface.Eval("({})", &root);

View File

@ -559,7 +559,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize)
memcpy(&len, buffer + readPos, sizeof(len));
ENSURE(len <= CProfiler2::MAX_ATTRIBUTE_LENGTH);
readPos += sizeof(len);
char message[CProfiler2::MAX_ATTRIBUTE_LENGTH] = {0};
memcpy(&message[0], buffer + readPos, len);
CStr mess = CStr((const char*)message, len);
@ -620,7 +620,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize)
}
curTime += std::get<1>(type.second);
float leave_time = (float)curTime;
buffer[writePos] = (u8)CProfiler2::ITEM_LEAVE;
memcpy(buffer + writePos + 1, &leave_time, sizeof(float));

View File

@ -157,7 +157,7 @@ public:
// That will be this GL_TIMESTAMP get, which potentially distorts the
// reported results. So we'll only do it fairly rarely, and for most
// frames we'll just assume the clocks don't drift much
const double RESYNC_PERIOD = 1.0; // seconds
double now = m_Profiler.GetTime();

View File

@ -548,7 +548,7 @@ void CTemplateLoader::CopyResourceSubset(CParamNode& out, const CParamNode& in)
CParamNode::LoadXMLString(out, "<Entity/>");
out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes);
// When dying, resources lose the unitMotion component
// This causes them to have no clearance. Since unit obstructions no longer have a radius,
// this makes them unreachable in some cases (see #3530).

View File

@ -329,7 +329,7 @@ private:
bool ProcessReport()
{
PROFILE2("process report");
shared_ptr<CUserReport> report;
{

View File

@ -92,7 +92,7 @@ bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
w, h, bpp, SDL_GetError());
// Using default size for the window for now, as the attempted setting
// could be as large, or larger than the screen size.
return SetVideoMode(DEFAULT_WINDOW_W, DEFAULT_WINDOW_H, bpp, false);
return SetVideoMode(DEFAULT_WINDOW_W, DEFAULT_WINDOW_H, bpp, false);
}
else
{

View File

@ -74,7 +74,7 @@ void CXeromyces::Terminate()
bool CXeromyces::AddValidator(const PIVFS& vfs, const std::string& name, const VfsPath& grammarPath)
{
ENSURE(g_XeromycesStarted);
RelaxNGValidator validator;
if (!validator.LoadGrammarFile(vfs, grammarPath))
{

View File

@ -38,7 +38,7 @@ bool JSI_ConfigDB::GetConfigNamespace(const std::wstring& cfgNsString, EConfigNa
{
LOGERROR("Invalid namespace name passed to the ConfigDB!");
cfgNs = CFG_DEFAULT;
return false;
return false;
}
return true;
}

View File

@ -24,7 +24,7 @@
#include "ps/Profile.h"
bool JSI_Console::CheckGlobalInitialized()
{
{
if (!g_Console)
{
LOGERROR("Trying to access the console when it's not initialized!");

View File

@ -28,7 +28,7 @@
///////////////////////////////////////////////////////////////////////////////
// CAlphaMapCalculator: functionality for calculating which alpha blend map
// fits a given shape
namespace CAlphaMapCalculator {
namespace CAlphaMapCalculator {
///////////////////////////////////////////////////////////////////////////////
// Blend4: structure mapping a blend shape for N,E,S,W to a particular map
@ -167,7 +167,7 @@ bool MatchBlendShapeFlipped(const T& templateshape,const T& shape,unsigned int&
flags|=BLENDMAP_FLIPV;
return true;
}
// no joy; no match by flipping
return false;
}
@ -192,7 +192,7 @@ int MatchBlendShape(const T& templateshape,const T& shape,unsigned int& flags)
flags|=flags ? BLENDMAP_ROTATE270 : BLENDMAP_ROTATE90;
return true;
}
templateshape.Rotate180(tstShape);
if (MatchBlendShapeFlipped(tstShape,shape,flags)) {
flags|=BLENDMAP_ROTATE180;
@ -236,7 +236,7 @@ int LookupBlend(int tableSize,const S* table,const T& shape,unsigned int& flags)
// Calculate: return the index of the blend map that fits the given shape,
// and the set of flip/rotation flags to get the shape correctly oriented
int Calculate(BlendShape8 shape,unsigned int& flags)
{
{
// assume we're not going to require flipping or rotating
flags=0;
@ -265,13 +265,13 @@ int Calculate(BlendShape8 shape,unsigned int& flags)
switch (count) {
case 1:
return LookupBlend(sizeof(Blends1Neighbour)/sizeof(Blend4),Blends1Neighbour,shape4,flags);
return LookupBlend(sizeof(Blends1Neighbour)/sizeof(Blend4),Blends1Neighbour,shape4,flags);
case 2:
return LookupBlend(sizeof(Blends2Neighbour)/sizeof(Blend4),Blends2Neighbour,shape4,flags);
return LookupBlend(sizeof(Blends2Neighbour)/sizeof(Blend4),Blends2Neighbour,shape4,flags);
case 3:
return LookupBlend(sizeof(Blends3Neighbour)/sizeof(Blend4),Blends3Neighbour,shape4,flags);
return LookupBlend(sizeof(Blends3Neighbour)/sizeof(Blend4),Blends3Neighbour,shape4,flags);
case 4:
// N,S,E,W have same texture, NE,SE,SW,NW don't; use a blend 4 corners
@ -289,22 +289,22 @@ int Calculate(BlendShape8 shape,unsigned int& flags)
return 0;
case 2:
return LookupBlend(sizeof(Blends2Neighbour8)/sizeof(Blend8),Blends2Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends2Neighbour8)/sizeof(Blend8),Blends2Neighbour8,shape,flags);
case 3:
return LookupBlend(sizeof(Blends3Neighbour8)/sizeof(Blend8),Blends3Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends3Neighbour8)/sizeof(Blend8),Blends3Neighbour8,shape,flags);
case 4:
return LookupBlend(sizeof(Blends4Neighbour8)/sizeof(Blend8),Blends4Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends4Neighbour8)/sizeof(Blend8),Blends4Neighbour8,shape,flags);
case 5:
return LookupBlend(sizeof(Blends5Neighbour8)/sizeof(Blend8),Blends5Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends5Neighbour8)/sizeof(Blend8),Blends5Neighbour8,shape,flags);
case 6:
return LookupBlend(sizeof(Blends6Neighbour8)/sizeof(Blend8),Blends6Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends6Neighbour8)/sizeof(Blend8),Blends6Neighbour8,shape,flags);
case 7:
return LookupBlend(sizeof(Blends7Neighbour8)/sizeof(Blend8),Blends7Neighbour8,shape,flags);
return LookupBlend(sizeof(Blends7Neighbour8)/sizeof(Blend8),Blends7Neighbour8,shape,flags);
}
}

View File

@ -83,57 +83,57 @@ void CDecalRData::RenderDecals(std::vector<CDecalRData*>& decals, const CShaderD
for (size_t i = 0; i < decals.size(); ++i)
{
CDecalRData *decal = decals[i];
CMaterial &material = decal->m_Decal->m_Decal.m_Material;
if (material.GetShaderEffect().length() == 0)
{
LOGERROR("Terrain renderer failed to load shader effect.\n");
continue;
}
int numPasses = 1;
CShaderTechniquePtr techBase;
if (!isDummyShader)
{
techBase = g_Renderer.GetShaderManager().LoadEffect(
material.GetShaderEffect(), contextDecal, material.GetShaderDefines(0));
if (!techBase)
{
LOGERROR("Terrain renderer failed to load shader effect (%s)\n",
LOGERROR("Terrain renderer failed to load shader effect (%s)\n",
material.GetShaderEffect().string().c_str());
continue;
}
numPasses = techBase->GetNumPasses();
}
for (int pass = 0; pass < numPasses; ++pass)
{
if (!isDummyShader)
{
techBase->BeginPass(pass);
TerrainRenderer::PrepareShader(techBase->GetShader(), shadow);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
const CShaderProgramPtr& shader = isDummyShader ? dummy : techBase->GetShader(pass);
if (material.GetSamplers().size() != 0)
{
const CMaterial::SamplersVector& samplers = material.GetSamplers();
size_t samplersNum = samplers.size();
for (size_t s = 0; s < samplersNum; ++s)
{
const CMaterial::TextureSampler& samp = samplers[s];
shader->BindTexture(samp.Name, samp.Sampler);
}
material.GetStaticUniforms().BindUniforms(shader);
// TODO: Need to handle floating decals correctly. In particular, we need
@ -160,7 +160,7 @@ void CDecalRData::RenderDecals(std::vector<CDecalRData*>& decals, const CShaderD
else
#endif
{
shader->Uniform(str_shadingColor, decal->m_Decal->GetShadingColor());
}
@ -182,7 +182,7 @@ void CDecalRData::RenderDecals(std::vector<CDecalRData*>& decals, const CShaderD
CVertexBuffer::Unbind();
}
if (!isDummyShader)
{
glDisable(GL_BLEND);

View File

@ -186,7 +186,7 @@ CModelRData* ShaderModelVertexRenderer::CreateModelData(const void* key, CModel*
void ShaderModelVertexRenderer::UpdateModelData(CModel* model, CModelRData* data, int updateflags)
{
ShaderModel* shadermodel = static_cast<ShaderModel*>(data);
if (!m->cpuLighting && (updateflags & RENDERDATA_UPDATE_VERTICES))
{
// build vertices

View File

@ -85,7 +85,7 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
m_UVs[i].elems = 2;
m_Array.AddAttribute(&m_UVs[i]);
}
if (gpuSkinning)
{
m_BlendJoints.type = GL_UNSIGNED_BYTE;
@ -96,33 +96,33 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
m_BlendWeights.elems = 4;
m_Array.AddAttribute(&m_BlendWeights);
}
if (calculateTangents)
{
// Generate tangents for the geometry:-
m_Tangent.type = GL_FLOAT;
m_Tangent.elems = 4;
m_Array.AddAttribute(&m_Tangent);
// floats per vertex; position + normal + tangent + UV*sets [+ GPUskinning]
int numVertexAttrs = 3 + 3 + 4 + 2 * mdef->GetNumUVsPerVertex();
if (gpuSkinning)
{
numVertexAttrs += 8;
}
// the tangent generation can increase the number of vertices temporarily
// so reserve a bit more memory to avoid reallocations in GenTangents (in most cases)
std::vector<float> newVertices;
newVertices.reserve(numVertexAttrs * numVertices * 2);
// Generate the tangents
ModelRenderer::GenTangents(mdef, newVertices, gpuSkinning);
// how many vertices do we have after generating tangents?
int newNumVert = newVertices.size() / numVertexAttrs;
std::vector<int> remapTable(newNumVert);
std::vector<float> vertexDataOut(newNumVert * numVertexAttrs);
@ -131,14 +131,14 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
&newVertices[0], newNumVert, numVertexAttrs);
// Copy the model data to graphics memory:-
m_Array.SetNumVertices(numVertices2);
m_Array.Layout();
VertexArrayIterator<CVector3D> Position = m_Position.GetIterator<CVector3D>();
VertexArrayIterator<CVector3D> Normal = m_Normal.GetIterator<CVector3D>();
VertexArrayIterator<CVector4D> Tangent = m_Tangent.GetIterator<CVector4D>();
VertexArrayIterator<u8[4]> BlendJoints;
VertexArrayIterator<u8[4]> BlendWeights;
if (gpuSkinning)
@ -146,22 +146,22 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
BlendJoints = m_BlendJoints.GetIterator<u8[4]>();
BlendWeights = m_BlendWeights.GetIterator<u8[4]>();
}
// copy everything into the vertex array
for (int i = 0; i < numVertices2; i++)
{
int q = numVertexAttrs * i;
Position[i] = CVector3D(vertexDataOut[q + 0], vertexDataOut[q + 1], vertexDataOut[q + 2]);
q += 3;
Normal[i] = CVector3D(vertexDataOut[q + 0], vertexDataOut[q + 1], vertexDataOut[q + 2]);
q += 3;
Tangent[i] = CVector4D(vertexDataOut[q + 0], vertexDataOut[q + 1], vertexDataOut[q + 2],
vertexDataOut[q + 3]);
q += 4;
if (gpuSkinning)
{
for (size_t j = 0; j < 4; ++j)
@ -171,7 +171,7 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
}
q += 8;
}
for (size_t j = 0; j < mdef->GetNumUVsPerVertex(); j++)
{
VertexArrayIterator<float[2]> UVit = m_UVs[j].GetIterator<float[2]>();
@ -186,26 +186,26 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
m_IndexArray.SetNumVertices(mdef->GetNumFaces() * 3);
m_IndexArray.Layout();
VertexArrayIterator<u16> Indices = m_IndexArray.GetIterator();
size_t idxidx = 0;
size_t idxidx = 0;
// reindex geometry and upload index
for (size_t j = 0; j < mdef->GetNumFaces(); ++j)
{
{
Indices[idxidx++] = remapTable[j * 3 + 0];
Indices[idxidx++] = remapTable[j * 3 + 1];
Indices[idxidx++] = remapTable[j * 3 + 2];
}
m_IndexArray.Upload();
m_IndexArray.FreeBackingStore();
}
else
{
// Upload model without calculating tangents:-
m_Array.SetNumVertices(numVertices);
m_Array.Layout();
@ -250,7 +250,7 @@ IModelDef::IModelDef(const CModelDefPtr& mdef, bool gpuSkinning, bool calculateT
struct InstancingModelRendererInternals
{
bool gpuSkinning;
bool calculateTangents;
/// Previously prepared modeldef
@ -333,13 +333,13 @@ void InstancingModelRenderer::PrepareModelDef(const CShaderProgramPtr& shader, i
if (streamflags & STREAM_NORMAL)
shader->NormalPointer(GL_FLOAT, stride, base + m->imodeldef->m_Normal.offset);
if (m->calculateTangents)
shader->VertexAttribPointer(str_a_tangent, 4, GL_FLOAT, GL_TRUE, stride, base + m->imodeldef->m_Tangent.offset);
if (streamflags & STREAM_UV0)
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, stride, base + m->imodeldef->m_UVs[0].offset);
if ((streamflags & STREAM_UV1) && def.GetNumUVsPerVertex() >= 2)
shader->TexCoordPointer(GL_TEXTURE1, 2, GL_FLOAT, stride, base + m->imodeldef->m_UVs[1].offset);

View File

@ -37,7 +37,7 @@ MikkTSpace::MikkTSpace(const CModelDefPtr& m, std::vector<float>& v, bool gpuSki
{
// ensure that m_NewVertices is empty
m_NewVertices.clear();
// set up SMikkTSpaceInterface struct
m_Interface.m_getNumFaces = getNumFaces;
m_Interface.m_getNumVerticesOfFace = getNumVerticesOfFace;
@ -105,7 +105,7 @@ void MikkTSpace::getTexCoord(const SMikkTSpaceContext *pContext,
// the tangents are calculated according to the 'default' UV set
fvTexcOut[0] = v.m_UVs[0];
fvTexcOut[1] = 1.0-v.m_UVs[1];
fvTexcOut[1] = 1.0-v.m_UVs[1];
}
@ -115,27 +115,27 @@ void MikkTSpace::setTSpace(const SMikkTSpaceContext * pContext, const float fvTa
{
SModelFace &face = ((MikkTSpace*)pContext->m_pUserData)->m_Model->GetFaces()[iFace];
long i = face.m_Verts[iVert];
SModelVertex* vertices = ((MikkTSpace*)pContext->m_pUserData)->m_Model->GetVertices();
size_t numUVsPerVertex = ((MikkTSpace*)pContext->m_pUserData)->m_Model->GetNumUVsPerVertex();
std::vector<float>& m_NewVertices = ((MikkTSpace*)pContext->m_pUserData)->m_NewVertices;
const CVector3D &p = vertices[i].m_Coords;
const CVector3D &n = vertices[i].m_Norm;
const CVector3D &n = vertices[i].m_Norm;
m_NewVertices.push_back(p.X);
m_NewVertices.push_back(p.Y);
m_NewVertices.push_back(p.Z);
m_NewVertices.push_back(n.X);
m_NewVertices.push_back(n.Y);
m_NewVertices.push_back(n.Z);
m_NewVertices.push_back(fvTangent[0]);
m_NewVertices.push_back(fvTangent[1]);
m_NewVertices.push_back(fvTangent[2]);
m_NewVertices.push_back(bIsOrientationPreserving > 0.5 ? 1.0f : (-1.0f));
if (((MikkTSpace*)pContext->m_pUserData)->m_GpuSkinning)
{
for (size_t j = 0; j < 4; ++j)

View File

@ -453,13 +453,13 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
{
CVector3D modelpos = model->GetTransform().GetTranslation();
float dist = worldToCam.Transform(modelpos).Z;
float dmin = item.m_CondArgs[0];
float dmax = item.m_CondArgs[1];
if ((dmin < 0 || dist >= dmin) && (dmax < 0 || dist < dmax))
condFlags |= (1 << j);
break;
}
}
@ -600,14 +600,14 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
PROFILE3("rendering bucketed submissions");
size_t idxTechStart = 0;
// This vector keeps track of texture changes during rendering. It is kept outside the
// loops to avoid excessive reallocations. The token allocation of 64 elements
// should be plenty, though it is reallocated below (at a cost) if necessary.
typedef ProxyAllocator<CTexture*, Allocators::DynamicArena> TextureListAllocator;
std::vector<CTexture*, TextureListAllocator> currentTexs((TextureListAllocator(arena)));
currentTexs.reserve(64);
// texBindings holds the identifier bindings in the shader, which can no longer be defined
// statically in the ShaderRenderModifier class. texBindingNames uses interned strings to
// keep track of when bindings need to be reevaluated.
@ -642,14 +642,14 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
modifier->BeginPass(shader);
m->vertexRenderer->BeginPass(streamflags);
// When the shader technique changes, textures need to be
// rebound, so ensure there are no remnants from the last pass.
// (the vector size is set to 0, but memory is not freed)
currentTexs.clear();
texBindings.clear();
texBindingNames.clear();
CModelDef* currentModeldef = NULL;
CShaderUniforms currentStaticUniforms;
@ -666,7 +666,7 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
const CMaterial::SamplersVector& samplers = model->GetMaterial().GetSamplers();
size_t samplersNum = samplers.size();
// make sure the vectors are the right virtual sizes, and also
// reallocate if there are more samplers than expected.
if (currentTexs.size() != samplersNum)
@ -674,18 +674,18 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
currentTexs.resize(samplersNum, NULL);
texBindings.resize(samplersNum, CShaderProgram::Binding());
texBindingNames.resize(samplersNum, CStrIntern());
// ensure they are definitely empty
std::fill(texBindings.begin(), texBindings.end(), CShaderProgram::Binding());
std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)NULL);
std::fill(texBindingNames.begin(), texBindingNames.end(), CStrIntern());
}
// bind the samplers to the shader
for (size_t s = 0; s < samplersNum; ++s)
{
const CMaterial::TextureSampler& samp = samplers[s];
CShaderProgram::Binding bind = texBindings[s];
// check that the handles are current
// and reevaluate them if necessary
@ -708,7 +708,7 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
currentTexs[s] = newTex;
}
}
// Bind modeldef when it changes
CModelDef* newModeldef = model->GetModelDef().get();
if (newModeldef != currentModeldef)
@ -724,9 +724,9 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
currentStaticUniforms = newStaticUniforms;
currentStaticUniforms.BindUniforms(shader);
}
const CShaderRenderQueries& renderQueries = model->GetMaterial().GetRenderQueries();
for (size_t q = 0; q < renderQueries.GetSize(); q++)
{
CShaderRenderQueries::RenderQuery rq = renderQueries.GetItem(q);
@ -745,7 +745,7 @@ void ShaderModelRenderer::Render(const RenderModifierPtr& modifier, const CShade
double time = WaterMgr->m_WaterTexTimer;
double period = 1.6;
int curTex = (int)(time*60/period) % 60;
if (WaterMgr->m_RenderWater && WaterMgr->WillRenderFancyWater())
shader->BindTexture(str_waterTex, WaterMgr->m_NormalMap[curTex]);
else

View File

@ -154,7 +154,7 @@ void OverlayRendererInternals::Initialize()
// Perform any initialization after graphics capabilities have been detected. Notably,
// only at this point can we safely allocate VBOs (in contrast to e.g. in the constructor),
// because their creation depends on the shader path, which is not reliably set before this point.
quadVertices.SetNumVertices(MAX_QUAD_OVERLAYS * 4);
quadVertices.Layout(); // allocate backing store
@ -244,7 +244,7 @@ void OverlayRenderer::EndFrame()
// this should leave the capacity unchanged, which is okay since it
// won't be very large or very variable
// Empty the batch rendering data structures, but keep their key mappings around for the next frames
for (OverlayRendererInternals::QuadBatchMap::iterator it = m->quadBatchMap.begin(); it != m->quadBatchMap.end(); ++it)
{
@ -323,7 +323,7 @@ void OverlayRenderer::PrepareForRendering()
*vertexPos++ = quad->m_Corners[1] + vOffset;
*vertexPos++ = quad->m_Corners[2] + vOffset;
*vertexPos++ = quad->m_Corners[3] + vOffset;
(*vertexUV)[0] = 0;
(*vertexUV)[1] = 0;
++vertexUV;
@ -551,10 +551,10 @@ void OverlayRenderer::RenderQuadOverlays()
if (streamflags & STREAM_UV1)
shader->TexCoordPointer(GL_TEXTURE1, m->quadAttributeUV.elems, m->quadAttributeUV.type, vertexStride, vertexBase + m->quadAttributeUV.offset);
if (streamflags & STREAM_COLOR)
shader->ColorPointer(m->quadAttributeColor.elems, m->quadAttributeColor.type, vertexStride, vertexBase + m->quadAttributeColor.offset);
shader->AssertPointersBound();
glDrawElements(GL_TRIANGLES, (GLsizei)(batchNumQuads * 6), GL_UNSIGNED_SHORT, indexBase + indexStride * batchRenderData.m_IndicesBase);
@ -596,10 +596,10 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
CShaderProgramPtr shader;
CShaderTechniquePtr tech;
if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER)
{
tech = g_Renderer.GetShaderManager().LoadEffect(str_foreground_overlay);
@ -608,7 +608,7 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
}
float uvs[8] = { 0,1, 1,1, 1,0, 0,0 };
if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER)
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, sizeof(float)*2, &uvs[0]);
else
@ -617,12 +617,12 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
for (size_t i = 0; i < m->sprites.size(); ++i)
{
SOverlaySprite* sprite = m->sprites[i];
if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER)
shader->BindTexture(str_baseTex, sprite->m_Texture);
else
sprite->m_Texture->Bind();
shader->Uniform(str_colorMul, sprite->m_Color);
CVector3D pos[4] = {
@ -636,13 +636,13 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
shader->VertexPointer(3, GL_FLOAT, sizeof(float)*3, &pos[0].X);
else
glVertexPointer(3, GL_FLOAT, sizeof(float)*3, &pos[0].X);
glDrawArrays(GL_QUADS, 0, (GLsizei)4);
g_Renderer.GetStats().m_DrawCalls++;
g_Renderer.GetStats().m_OverlayTris += 2;
}
if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER)
tech->EndPass();

View File

@ -334,7 +334,7 @@ void CPatchRData::AddBlend(std::vector<SBlendVertex>& blendVertices, std::vector
// now actually render the blend tile (if we need one)
if (alphamap == -1)
return;
float u0 = texture->m_TerrainAlpha->second.m_AlphaMapCoords[alphamap].u0;
float u1 = texture->m_TerrainAlpha->second.m_AlphaMapCoords[alphamap].u1;
float v0 = texture->m_TerrainAlpha->second.m_AlphaMapCoords[alphamap].v0;
@ -469,7 +469,7 @@ void CPatchRData::BuildIndices()
m_Splats.resize(textures.size());
// build indices for base splats
size_t base=m_VBBase->m_Index;
for (size_t i=0;i<m_Splats.size();i++) {
CTerrainTextureEntry* tex=textures[i];
@ -561,7 +561,7 @@ void CPatchRData::BuildVertices()
// for all vertices, it need not be stored in the vertex structure)
CVector3D normal;
terrain->CalcNormal(ix,iz,normal);
vertices[v].m_Normal = normal;
vertices[v].m_DiffuseColor = cpuLighting ? lightEnv.EvaluateTerrainDiffuseScaled(normal) : lightEnv.EvaluateTerrainDiffuseFactor(normal);
@ -762,9 +762,9 @@ void CPatchRData::RenderBases(const std::vector<CPatchRData*>& patches, const CS
for (TextureBatches::iterator itt = batches.begin(); itt != batches.end(); ++itt)
{
int numPasses = 1;
CShaderTechniquePtr techBase;
if (!isDummyShader)
{
if (itt->first->GetMaterial().GetShaderEffect().length() == 0)
@ -772,13 +772,13 @@ void CPatchRData::RenderBases(const std::vector<CPatchRData*>& patches, const CS
LOGERROR("Terrain renderer failed to load shader effect.\n");
continue;
}
techBase = g_Renderer.GetShaderManager().LoadEffect(itt->first->GetMaterial().GetShaderEffect(),
context, itt->first->GetMaterial().GetShaderDefines(0));
numPasses = techBase->GetNumPasses();
}
for (int pass = 0; pass < numPasses; ++pass)
{
if (!isDummyShader)
@ -786,20 +786,20 @@ void CPatchRData::RenderBases(const std::vector<CPatchRData*>& patches, const CS
techBase->BeginPass(pass);
TerrainRenderer::PrepareShader(techBase->GetShader(), shadow);
}
const CShaderProgramPtr& shader = isDummyShader ? dummy : techBase->GetShader(pass);
if (itt->first->GetMaterial().GetSamplers().size() != 0)
{
const CMaterial::SamplersVector& samplers = itt->first->GetMaterial().GetSamplers();
size_t samplersNum = samplers.size();
for (size_t s = 0; s < samplersNum; ++s)
{
const CMaterial::TextureSampler& samp = samplers[s];
shader->BindTexture(samp.Name, samp.Sampler);
}
itt->first->GetMaterial().GetStaticUniforms().BindUniforms(shader);
#if !CONFIG2_GLES
@ -852,7 +852,7 @@ void CPatchRData::RenderBases(const std::vector<CPatchRData*>& patches, const CS
g_Renderer.m_Stats.m_TerrainTris += std::accumulate(batch.first.begin(), batch.first.end(), 0) / 3;
}
}
if (!isDummyShader)
techBase->EndPass();
}
@ -908,7 +908,7 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
typedef std::vector<SBlendBatch, ProxyAllocator<SBlendBatch, Allocators::DynamicArena > > BatchesStack;
BatchesStack batches((BatchesStack::allocator_type(arena)));
CShaderDefines contextBlend = context;
contextBlend.Add(str_BLEND, str_1);
@ -991,20 +991,20 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
CVertexBuffer* lastVB = NULL;
for (BatchesStack::iterator itt = batches.begin(); itt != batches.end(); ++itt)
{
{
if (itt->m_Texture->GetMaterial().GetSamplers().size() == 0)
continue;
int numPasses = 1;
CShaderTechniquePtr techBase;
if (!isDummyShader)
{
techBase = g_Renderer.GetShaderManager().LoadEffect(itt->m_Texture->GetMaterial().GetShaderEffect(), contextBlend, itt->m_Texture->GetMaterial().GetShaderDefines(0));
numPasses = techBase->GetNumPasses();
}
CShaderProgramPtr previousShader;
for (int pass = 0; pass < numPasses; ++pass)
{
@ -1012,18 +1012,18 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
{
techBase->BeginPass(pass);
TerrainRenderer::PrepareShader(techBase->GetShader(), shadow);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
const CShaderProgramPtr& shader = isDummyShader ? dummy : techBase->GetShader(pass);
if (itt->m_Texture)
{
const CMaterial::SamplersVector& samplers = itt->m_Texture->GetMaterial().GetSamplers();
size_t samplersNum = samplers.size();
for (size_t s = 0; s < samplersNum; ++s)
{
const CMaterial::TextureSampler& samp = samplers[s];
@ -1033,7 +1033,7 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
shader->BindTexture(str_blendTex, itt->m_Texture->m_TerrainAlpha->second.m_hCompositeAlphaMap);
itt->m_Texture->GetMaterial().GetStaticUniforms().BindUniforms(shader);
#if !CONFIG2_GLES
if (isDummyShader)
{
@ -1091,7 +1091,7 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
g_Renderer.m_Stats.m_TerrainTris += std::accumulate(batch.first.begin(), batch.first.end(), 0) / 3;
}
}
if (!isDummyShader)
{
glDisable(GL_BLEND);
@ -1311,7 +1311,7 @@ void CPatchRData::BuildWater()
CmpPtr<ICmpWaterManager> cmpWaterManager(*m_Simulation, SYSTEM_ENTITY);
if (!cmpWaterManager)
return;
// Build data for water
std::vector<SWaterVertex> water_vertex_data;
std::vector<GLushort> water_indices;
@ -1323,14 +1323,14 @@ void CPatchRData::BuildWater()
std::vector<GLushort> water_indices_shore;
u16 water_shore_index_map[PATCH_SIZE+1][PATCH_SIZE+1];
memset(water_shore_index_map, 0xFF, sizeof(water_shore_index_map));
WaterManager* WaterMgr = g_Renderer.GetWaterManager();
CPatch* patch = m_Patch;
CTerrain* terrain = patch->m_Parent;
ssize_t mapSize = (size_t)terrain->GetVerticesPerSide();
//Top-left coordinates of our patch.
ssize_t x1 = m_Patch->m_X*PATCH_SIZE;
ssize_t z1 = m_Patch->m_Z*PATCH_SIZE;
@ -1342,13 +1342,13 @@ void CPatchRData::BuildWater()
int moves[4][2] = { {0,0}, {water_cell_size,0}, {0,water_cell_size}, {water_cell_size,water_cell_size} };
// Where to look for when checking for water for shore tiles.
int check[10][2] = { {0,0},{water_cell_size,0},{water_cell_size*2,0},{0,water_cell_size},{0,water_cell_size*2},{water_cell_size,water_cell_size},{water_cell_size*2,water_cell_size*2}, {-water_cell_size,0}, {0,-water_cell_size}, {-water_cell_size,-water_cell_size} };
// build vertices, uv, and shader varying
for (ssize_t z = 0; z < PATCH_SIZE; z += water_cell_size)
{
for (ssize_t x = 0; x < PATCH_SIZE; x += water_cell_size)
{
// Check that this tile is close to water
bool nearWat = false;
for (size_t test = 0; test < 10; ++test)
@ -1356,32 +1356,32 @@ void CPatchRData::BuildWater()
nearWat = true;
if (!nearWat)
continue;
// This is actually lying and I should call CcmpTerrain
/*if (!terrain->IsOnMap(x+x1, z+z1)
&& !terrain->IsOnMap(x+x1, z+z1 + water_cell_size)
&& !terrain->IsOnMap(x+x1 + water_cell_size, z+z1)
&& !terrain->IsOnMap(x+x1 + water_cell_size, z+z1 + water_cell_size))
continue;*/
for (int i = 0; i < 4; ++i)
{
if (water_index_map[z+moves[i][1]][x+moves[i][0]] != 0xFFFF)
continue;
ssize_t zz = z+z1+moves[i][1];
ssize_t xx = x+x1+moves[i][0];
SWaterVertex vertex;
terrain->CalcPosition(xx,zz, vertex.m_Position);
float depth = waterHeight - vertex.m_Position.Y;
vertex.m_Position.Y = waterHeight;
m_WaterBounds += vertex.m_Position;
vertex.m_WaterData = CVector2D(WaterMgr->m_WindStrength[xx + zz*mapSize], depth);
water_index_map[z+moves[i][1]][x+moves[i][0]] = water_vertex_data.size();
water_vertex_data.push_back(vertex);
}
@ -1391,7 +1391,7 @@ void CPatchRData::BuildWater()
water_indices.push_back(water_index_map[z + moves[1][1]][x + moves[1][0]]);
water_indices.push_back(water_index_map[z + moves[3][1]][x + moves[3][0]]);
water_indices.push_back(water_index_map[z + moves[2][1]][x + moves[2][0]]);
// Check id this tile is partly over land.
// If so add a square over the terrain. This is necessary to render waves that go on shore.
if (terrain->GetVertexGroundLevel(x+x1, z+z1) < waterHeight
@ -1399,22 +1399,22 @@ void CPatchRData::BuildWater()
&& terrain->GetVertexGroundLevel(x+x1, z+z1+water_cell_size) < waterHeight
&& terrain->GetVertexGroundLevel(x+x1 + water_cell_size, z+z1+water_cell_size) < waterHeight)
continue;
for (int i = 0; i < 4; ++i)
{
if (water_shore_index_map[z+moves[i][1]][x+moves[i][0]] != 0xFFFF)
continue;
ssize_t zz = z+z1+moves[i][1];
ssize_t xx = x+x1+moves[i][0];
SWaterVertex vertex;
terrain->CalcPosition(xx,zz, vertex.m_Position);
vertex.m_Position.Y += 0.02f;
m_WaterBounds += vertex.m_Position;
vertex.m_WaterData = CVector2D(0.0f, -5.0f);
water_shore_index_map[z+moves[i][1]][x+moves[i][0]] = water_vertex_data_shore.size();
water_vertex_data_shore.push_back(vertex);
}
@ -1444,7 +1444,7 @@ void CPatchRData::BuildWater()
{
m_VBWater = g_VBMan.Allocate(sizeof(SWaterVertex), water_vertex_data.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER);
m_VBWater->m_Owner->UpdateChunkVertices(m_VBWater, &water_vertex_data[0]);
m_VBWaterIndices = g_VBMan.Allocate(sizeof(GLushort), water_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
m_VBWaterIndices->m_Owner->UpdateChunkVertices(m_VBWaterIndices, &water_indices[0]);
}
@ -1453,7 +1453,7 @@ void CPatchRData::BuildWater()
{
m_VBWaterShore = g_VBMan.Allocate(sizeof(SWaterVertex), water_vertex_data_shore.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER);
m_VBWaterShore->m_Owner->UpdateChunkVertices(m_VBWaterShore, &water_vertex_data_shore[0]);
// Construct indices buffer
m_VBWaterIndicesShore = g_VBMan.Allocate(sizeof(GLushort), water_indices_shore.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
m_VBWaterIndicesShore->m_Owner->UpdateChunkVertices(m_VBWaterIndicesShore, &water_indices_shore[0]);
@ -1469,37 +1469,37 @@ void CPatchRData::RenderWater(CShaderProgramPtr& shader, bool onlyShore, bool fi
if (m_VBWater != 0x0 && !onlyShore)
{
SWaterVertex *base=(SWaterVertex *)m_VBWater->m_Owner->Bind();
// setup data pointers
GLsizei stride = sizeof(SWaterVertex);
shader->VertexPointer(3, GL_FLOAT, stride, &base[m_VBWater->m_Index].m_Position);
if (!fixedPipeline)
shader->VertexAttribPointer(str_a_waterInfo, 2, GL_FLOAT, false, stride, &base[m_VBWater->m_Index].m_WaterData);
shader->AssertPointersBound();
u8* indexBase = m_VBWaterIndices->m_Owner->Bind();
glDrawElements(GL_TRIANGLES, (GLsizei) m_VBWaterIndices->m_Count,
GL_UNSIGNED_SHORT, indexBase + sizeof(u16)*(m_VBWaterIndices->m_Index));
g_Renderer.m_Stats.m_DrawCalls++;
g_Renderer.m_Stats.m_WaterTris += m_VBWaterIndices->m_Count / 3;
}
if (m_VBWaterShore != 0x0 && g_Renderer.GetWaterManager()->m_WaterFancyEffects && !g_Renderer.GetWaterManager()->m_WaterUgly)
{
SWaterVertex *base=(SWaterVertex *)m_VBWaterShore->m_Owner->Bind();
GLsizei stride = sizeof(SWaterVertex);
shader->VertexPointer(3, GL_FLOAT, stride, &base[m_VBWaterShore->m_Index].m_Position);
if (!fixedPipeline)
shader->VertexAttribPointer(str_a_waterInfo, 2, GL_FLOAT, false, stride, &base[m_VBWaterShore->m_Index].m_WaterData);
shader->AssertPointersBound();
u8* indexBase = m_VBWaterIndicesShore->m_Owner->Bind();
glDrawElements(GL_TRIANGLES, (GLsizei) m_VBWaterIndicesShore->m_Count,
GL_UNSIGNED_SHORT, indexBase + sizeof(u16)*(m_VBWaterIndicesShore->m_Index));
g_Renderer.m_Stats.m_DrawCalls++;
g_Renderer.m_Stats.m_WaterTris += m_VBWaterIndicesShore->m_Count / 3;
}

View File

@ -110,26 +110,26 @@ void CPostprocManager::RecreateBuffers()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); \
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); \
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Two fullscreen ping-pong textures.
GEN_BUFFER_RGBA(m_ColorTex1, m_Width, m_Height);
GEN_BUFFER_RGBA(m_ColorTex2, m_Width, m_Height);
// Textures for several blur sizes. It would be possible to reuse
// m_BlurTex2b, thus avoiding the need for m_BlurTex4b and m_BlurTex8b, though given
// that these are fairly small it's probably not worth complicating the coordinates passed
// to the blur helper functions.
GEN_BUFFER_RGBA(m_BlurTex2a, m_Width / 2, m_Height / 2);
GEN_BUFFER_RGBA(m_BlurTex2b, m_Width / 2, m_Height / 2);
GEN_BUFFER_RGBA(m_BlurTex4a, m_Width / 4, m_Height / 4);
GEN_BUFFER_RGBA(m_BlurTex4b, m_Width / 4, m_Height / 4);
GEN_BUFFER_RGBA(m_BlurTex8a, m_Width / 8, m_Height / 8);
GEN_BUFFER_RGBA(m_BlurTex8b, m_Width / 8, m_Height / 8);
#undef GEN_BUFFER_RGBA
// Allocate the Depth/Stencil texture.
glGenTextures(1, (GLuint*)&m_DepthTex);
glBindTexture(GL_TEXTURE_2D, m_DepthTex);
@ -142,11 +142,11 @@ void CPostprocManager::RecreateBuffers()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
// Set up the framebuffers with some initial textures.
pglGenFramebuffersEXT(1, &m_PingFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
@ -155,13 +155,13 @@ void CPostprocManager::RecreateBuffers()
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, m_DepthTex, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Framebuffer object incomplete (A): 0x%04X", status);
}
pglGenFramebuffersEXT(1, &m_PongFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
@ -170,20 +170,20 @@ void CPostprocManager::RecreateBuffers()
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, m_DepthTex, 0);
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Framebuffer object incomplete (B): 0x%04X", status);
}
pglGenFramebuffersEXT(1, &m_BloomFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
/*
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, m_BloomTex1, 0);
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
@ -200,18 +200,18 @@ void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inW
// Bind inTex to framebuffer for rendering.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, outTex, 0);
// Get bloom shader with instructions to simply copy texels.
CShaderDefines defines;
defines.Add(str_BLOOM_NOP, str_1);
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom,
g_Renderer.GetSystemShaderDefines(), defines);
tech->BeginPass();
CShaderProgramPtr shader = tech->GetShader();
GLuint renderedTex = inTex;
// Cheat by creating high quality mipmaps for inTex, so the copying operation actually
// produces good scaling due to hardware filtering.
glBindTexture(GL_TEXTURE_2D, renderedTex);
@ -219,13 +219,13 @@ void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inW
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
shader->BindTexture(str_renderedTex, renderedTex);
const SViewPort oldVp = g_Renderer.GetViewport();
const SViewPort vp = { 0, 0, inWidth / 2, inHeight / 2 };
g_Renderer.SetViewport(vp);
float quadVerts[] = {
1.0f, 1.0f,
-1.0f, 1.0f,
@ -250,7 +250,7 @@ void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inW
glDrawArrays(GL_TRIANGLES, 0, 6);
g_Renderer.SetViewport(oldVp);
tech->EndPass();
}
@ -259,22 +259,22 @@ void CPostprocManager::ApplyBlurGauss(GLuint inOutTex, GLuint tempTex, int inWid
// Set tempTex as our rendering target.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tempTex, 0);
// Get bloom shader, for a horizontal Gaussian blur pass.
CShaderDefines defines2;
defines2.Add(str_BLOOM_PASS_H, str_1);
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom,
g_Renderer.GetSystemShaderDefines(), defines2);
tech->BeginPass();
CShaderProgramPtr shader = tech->GetShader();
shader->BindTexture(str_renderedTex, inOutTex);
shader->Uniform(str_texSize, inWidth, inHeight, 0.0f, 0.0f);
const SViewPort oldVp = g_Renderer.GetViewport();
const SViewPort vp = { 0, 0, inWidth, inHeight };
g_Renderer.SetViewport(vp);
float quadVerts[] = {
1.0f, 1.0f,
-1.0f, 1.0f,
@ -301,26 +301,26 @@ void CPostprocManager::ApplyBlurGauss(GLuint inOutTex, GLuint tempTex, int inWid
g_Renderer.SetViewport(oldVp);
tech->EndPass();
// Set result texture as our render target.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, inOutTex, 0);
// Get bloom shader, for a vertical Gaussian blur pass.
CShaderDefines defines3;
defines3.Add(str_BLOOM_PASS_V, str_1);
tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom,
g_Renderer.GetSystemShaderDefines(), defines3);
tech->BeginPass();
shader = tech->GetShader();
// Our input texture to the shader is the output of the horizontal pass.
shader->BindTexture(str_renderedTex, tempTex);
shader->Uniform(str_texSize, inWidth, inHeight, 0.0f, 0.0f);
g_Renderer.SetViewport(vp);
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 0, quadTex);
shader->VertexPointer(2, GL_FLOAT, 0, quadVerts);
shader->AssertPointersBound();
@ -334,25 +334,25 @@ void CPostprocManager::ApplyBlurGauss(GLuint inOutTex, GLuint tempTex, int inWid
void CPostprocManager::ApplyBlur()
{
glDisable(GL_BLEND);
GLint originalFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &originalFBO);
int width = m_Width, height = m_Height;
#define SCALE_AND_BLUR(tex1, tex2, temptex) \
ApplyBlurDownscale2x(tex1, tex2, width, height); \
width /= 2; \
height /= 2; \
ApplyBlurGauss(tex2, temptex, width, height);
// We do the same thing for each scale, incrementally adding more and more blur.
SCALE_AND_BLUR(m_WhichBuffer ? m_ColorTex1 : m_ColorTex2, m_BlurTex2a, m_BlurTex2b);
SCALE_AND_BLUR(m_BlurTex2a, m_BlurTex4a, m_BlurTex4b);
SCALE_AND_BLUR(m_BlurTex4a, m_BlurTex8a, m_BlurTex8b);
#undef SCALE_AND_BLUR
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, originalFBO);
}
@ -363,16 +363,16 @@ void CPostprocManager::CaptureRenderOutput()
// clear both FBOs and leave m_PingFbo selected for rendering;
// m_WhichBuffer stays true at this point
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
pglDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
pglDrawBuffers(1, buffers);
m_WhichBuffer = true;
}
@ -383,18 +383,18 @@ void CPostprocManager::ReleaseRenderOutput()
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// we blit to screen from the previous active buffer
if (m_WhichBuffer)
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PingFbo);
else
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PongFbo);
pglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
pglBlitFramebufferEXT(0, 0, m_Width, m_Height, 0, 0, m_Width, m_Height,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
@ -405,15 +405,15 @@ void CPostprocManager::ApplyEffect(CShaderTechniquePtr &shaderTech1, int pass)
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
else
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
shaderTech1->BeginPass(pass);
CShaderProgramPtr shader = shaderTech1->GetShader(pass);
shader->Bind();
// Use the textures from the current FBO as input to the shader.
// We also bind a bunch of other textures and parameters, but since
// this only happens once per frame the overhead is negligible.
@ -421,23 +421,23 @@ void CPostprocManager::ApplyEffect(CShaderTechniquePtr &shaderTech1, int pass)
shader->BindTexture(str_renderedTex, m_ColorTex1);
else
shader->BindTexture(str_renderedTex, m_ColorTex2);
shader->BindTexture(str_depthTex, m_DepthTex);
shader->BindTexture(str_blurTex2, m_BlurTex2a);
shader->BindTexture(str_blurTex4, m_BlurTex4a);
shader->BindTexture(str_blurTex8, m_BlurTex8a);
shader->Uniform(str_width, m_Width);
shader->Uniform(str_height, m_Height);
shader->Uniform(str_zNear, g_Game->GetView()->GetNear());
shader->Uniform(str_zFar, g_Game->GetView()->GetFar());
shader->Uniform(str_brightness, g_LightEnv.m_Brightness);
shader->Uniform(str_hdr, g_LightEnv.m_Contrast);
shader->Uniform(str_saturation, g_LightEnv.m_Saturation);
shader->Uniform(str_bloom, g_LightEnv.m_Bloom);
float quadVerts[] = {
1.0f, 1.0f,
-1.0f, 1.0f,
@ -460,14 +460,14 @@ void CPostprocManager::ApplyEffect(CShaderTechniquePtr &shaderTech1, int pass)
shader->VertexPointer(2, GL_FLOAT, 0, quadVerts);
shader->AssertPointersBound();
glDrawArrays(GL_TRIANGLES, 0, 6);
shader->Unbind();
shaderTech1->EndPass(pass);
shaderTech1->EndPass(pass);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
m_WhichBuffer = !m_WhichBuffer;
}
@ -478,33 +478,33 @@ void CPostprocManager::ApplyPostproc()
// Don't do anything if we are using the default effect.
if (m_PostProcEffect == L"default")
return;
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT };
pglDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
pglDrawBuffers(1, buffers);
pglDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
// First render blur textures. Note that this only happens ONLY ONCE, before any effects are applied!
// (This may need to change depending on future usage, however that will have a fps hit)
ApplyBlur();
for (int pass = 0; pass < m_PostProcTech->GetNumPasses(); ++pass)
ApplyEffect(m_PostProcTech, pass);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
}
@ -562,7 +562,7 @@ void CPostprocManager::ApplyBlurGauss(GLuint UNUSED(inOutTex), GLuint UNUSED(tem
void CPostprocManager::ApplyEffect(CShaderTechniquePtr &UNUSED(shaderTech1), int UNUSED(pass))
{
}
CPostprocManager::CPostprocManager()
{
}
@ -599,7 +599,7 @@ void CPostprocManager::SetPostEffect(const CStrW& UNUSED(name))
void CPostprocManager::CaptureRenderOutput()
{
}
void CPostprocManager::ApplyPostproc()
{
}

View File

@ -90,7 +90,7 @@ void ShaderRenderModifier::BeginPass(const CShaderProgramPtr& shader)
shader->Uniform(str_ambient, GetLightEnv()->m_UnitsAmbientColor);
shader->Uniform(str_sunDir, GetLightEnv()->GetSunDir());
shader->Uniform(str_sunColor, GetLightEnv()->m_SunColor);
shader->Uniform(str_fogColor, GetLightEnv()->m_FogColor);
shader->Uniform(str_fogParams, GetLightEnv()->m_FogFactor, GetLightEnv()->m_FogMax, 0.f, 0.f);
}

View File

@ -289,13 +289,13 @@ public:
/// Material manager
CMaterialManager materialManager;
/// Time manager
CTimeManager timeManager;
/// Shadow map
ShadowMap shadow;
/// Postprocessing effect manager
CPostprocManager postprocManager;
@ -648,7 +648,7 @@ bool CRenderer::Open(int width, int height)
// Let component renderers perform one-time initialization after graphics capabilities and
// the shader path have been determined.
m->overlayRenderer.Initialize();
if (m_Options.m_Postproc)
m->postprocManager.Initialize();
@ -663,9 +663,9 @@ void CRenderer::Resize(int width, int height)
m_Width = width;
m_Height = height;
m->postprocManager.Resize();
m_WaterManager->Resize();
}
@ -856,7 +856,7 @@ void CRenderer::BeginFrame()
if (m->ShadersDirty)
ReloadShaders();
m->Model.ModShader->SetShadowMap(&m->shadow);
m->Model.ModShader->SetLightEnv(m_LightEnv);
}
@ -1175,7 +1175,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
// Save the post-processing framebuffer.
GLint fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo);
WaterManager& wm = m->waterManager;
// Remember old camera
@ -1202,7 +1202,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
// try binding the framebuffer
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_ReflectionFbo);
glClearColor(0.5f,0.5f,1.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -1224,7 +1224,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
ogl_WarnIfError();
}
glFrontFace(GL_CCW);
// Particles are always oriented to face the camera in the vertex shader,
// so they don't need the inverted glFrontFace
if (m_Options.m_Particles)
@ -1232,16 +1232,16 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
RenderParticles(CULL_REFLECTIONS);
ogl_WarnIfError();
}
glDisable(GL_SCISSOR_TEST);
// Reset old camera
m_ViewCamera = normalCamera;
m->SetOpenGLCamera(m_ViewCamera);
// rebind post-processing frambuffer.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
return;
}
@ -1255,7 +1255,7 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding
// Save the post-processing framebuffer.
GLint fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo);
WaterManager& wm = m->waterManager;
// Remember old camera
@ -1282,13 +1282,13 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding
glEnable(GL_SCISSOR_TEST);
glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1);
// try binding the framebuffer
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_RefractionFbo);
glClearColor(1.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render terrain and models
RenderPatches(context, CULL_REFRACTIONS);
ogl_WarnIfError();
@ -1296,16 +1296,16 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding
ogl_WarnIfError();
RenderTransparentModels(context, CULL_REFRACTIONS, TRANSPARENT_OPAQUE, false);
ogl_WarnIfError();
glDisable(GL_SCISSOR_TEST);
// Reset old camera
m_ViewCamera = normalCamera;
m->SetOpenGLCamera(m_ViewCamera);
// rebind post-processing frambuffer.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
return;
}
@ -1447,9 +1447,9 @@ void CRenderer::RenderParticles(int cullGroup)
void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor)
{
PROFILE3("render submissions");
GetScene().GetLOSTexture().InterpolateLOS();
if (m_Options.m_Postproc)
{
m->postprocManager.Initialize();
@ -1562,7 +1562,7 @@ void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor)
RenderParticles(cullGroup);
ogl_WarnIfError();
}
if (m_Options.m_Postproc)
{
m->postprocManager.ApplyPostproc();
@ -1594,7 +1594,7 @@ void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor)
// render overlays that should appear on top of all other objects
m->overlayRenderer.RenderForegroundOverlays(m_ViewCamera);
ogl_WarnIfError();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2017,9 +2017,9 @@ int CRenderer::LoadAlphaMaps()
// upload the composite texture
Tex t;
(void)t.wrap(total_w, total_h, 8, TEX_GREY, data, 0);
/*VfsPath filename("blendtex.png");
DynArray da;
RETURN_STATUS_IF_ERR(tex_encode(&t, filename.Extension(), &da));
@ -2035,7 +2035,7 @@ int CRenderer::LoadAlphaMaps()
}
(void)da_free(&da);*/
m_hCompositeAlphaMap = ogl_tex_wrap(&t, g_VFS, key);
(void)ogl_tex_set_filter(m_hCompositeAlphaMap, GL_LINEAR);
(void)ogl_tex_set_wrap (m_hCompositeAlphaMap, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);

View File

@ -87,7 +87,7 @@ struct ShadowMapInternals
// Copy of renderer's standard view camera, saved between
// BeginRender and EndRender while we replace it with the shadow camera
CCamera SavedViewCamera;
// Save the caller's FBO so it can be restored
GLint SavedViewFBO;
@ -372,8 +372,8 @@ void ShadowMapInternals::CreateTexture()
pglDeleteFramebuffersEXT(1, &Framebuffer);
Framebuffer = 0;
}
// save the caller's FBO
// save the caller's FBO
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &SavedViewFBO);
pglGenFramebuffersEXT(1, &Framebuffer);
@ -507,7 +507,7 @@ void ShadowMapInternals::CreateTexture()
void ShadowMap::BeginRender()
{
// HACK HACK: this depends in non-obvious ways on the behaviour of the caller
// save caller's FBO
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &m->SavedViewFBO);

View File

@ -69,7 +69,7 @@ SkyManager::SkyManager()
m_SkySet = L"";
m_HorizonHeight = -150.0f;
m_SkyCubeMap = 0;
}
@ -92,10 +92,10 @@ void SkyManager::LoadSkyTextures()
///////////////////////////////////////////////////////////////////////////
// HACK: THE HORRIBLENESS HERE IS OVER 9000. The following code is a HUGE hack and will be removed completely
// as soon as all the hardcoded GL_TEXTURE_2D references are corrected in the TextureManager/OGL/tex libs.
glGenTextures(1, &m_SkyCubeMap);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_SkyCubeMap);
int types[] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
@ -104,7 +104,7 @@ void SkyManager::LoadSkyTextures()
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
};
const wchar_t* images[numTextures+1] = {
L"front",
L"back",
@ -113,11 +113,11 @@ void SkyManager::LoadSkyTextures()
L"top",
L"top"
};
for (size_t i = 0; i < numTextures+1; ++i)
{
VfsPath path = VfsPath("art/textures/skies") / m_SkySet / (Path::String(images[i])+L".dds");
shared_ptr<u8> file;
size_t fileSize;
if (g_VFS->LoadFile(path, file, fileSize) < 0)
@ -130,31 +130,31 @@ void SkyManager::LoadSkyTextures()
return;
}
}
Tex tex;
tex.decode(file, fileSize);
tex.transform_to((tex.m_Flags | TEX_BOTTOM_UP | TEX_ALPHA) & ~(TEX_DXT | TEX_MIPMAPS));
u8* data = tex.get_data();
if (types[i] == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y || types[i] == GL_TEXTURE_CUBE_MAP_POSITIVE_Y)
{
std::vector<u8> rotated(tex.m_DataSize);
for (size_t y = 0; y < tex.m_Height; ++y)
{
for (size_t x = 0; x < tex.m_Width; ++x)
{
size_t invx = y, invy = tex.m_Width-x-1;
rotated[(y*tex.m_Width + x) * 4 + 0] = data[(invy*tex.m_Width + invx) * 4 + 0];
rotated[(y*tex.m_Width + x) * 4 + 1] = data[(invy*tex.m_Width + invx) * 4 + 1];
rotated[(y*tex.m_Width + x) * 4 + 2] = data[(invy*tex.m_Width + invx) * 4 + 2];
rotated[(y*tex.m_Width + x) * 4 + 3] = data[(invy*tex.m_Width + invx) * 4 + 3];
}
}
glTexImage2D(types[i], 0, GL_RGB, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &rotated[0]);
}
else
@ -162,7 +162,7 @@ void SkyManager::LoadSkyTextures()
glTexImage2D(types[i], 0, GL_RGB, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@ -183,13 +183,13 @@ void SkyManager::SetSkySet( const CStrW& newSet )
{
if(newSet == m_SkySet)
return;
if (m_SkyCubeMap)
{
glDeleteTextures(1, &m_SkyCubeMap);
m_SkyCubeMap = 0;
}
m_SkySet = newSet;
LoadSkyTextures();
@ -228,19 +228,19 @@ void SkyManager::RenderSky()
// Draw the sky as a small box around the map, with depth write enabled.
// This will be done before anything else is drawn so we'll be overlapped by everything else.
// Do nothing unless SetSkySet was called
if (m_SkySet.empty())
return;
glDepthMask( GL_FALSE );
pglActiveTextureARB(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
// Translate so we are at the center of the map.
ssize_t mapSize = g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide();
glTranslatef(mapSize*(TERRAIN_TILE_SIZE/2.0f), m_HorizonHeight, mapSize*(TERRAIN_TILE_SIZE/2.0f) );
@ -253,10 +253,10 @@ void SkyManager::RenderSky()
const float D = 1500.0f; // distance from map center
const float H = 500.0f; // height of the ceiling
const float FH = -100.0f; // height of the "floor"
CShaderProgramPtr shader;
CShaderTechniquePtr skytech;
if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER)
{
skytech = g_Renderer.GetShaderManager().LoadEffect(str_sky_simple);
@ -284,19 +284,19 @@ void SkyManager::RenderSky()
glTexCoord3f( -1, +1, +1 ); glVertex3f( +D, FH, -D );
glTexCoord3f( -1, -1, +1 ); glVertex3f( +D, +H, -D );
glTexCoord3f( -1, -1, -1 ); glVertex3f( +D, +H, +D );
// GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
glTexCoord3f( -1, +1, +1 ); glVertex3f( +D, FH, -D );
glTexCoord3f( -1, +1, -1 ); glVertex3f( +D, FH, +D );
glTexCoord3f( +1, +1, -1 ); glVertex3f( -D, FH, +D );
glTexCoord3f( +1, +1, +1 ); glVertex3f( -D, FH, -D );
// GL_TEXTURE_CUBE_MAP_POSITIVE_Y
glTexCoord3f( +1, -1, +1 ); glVertex3f( -D, +H, -D );
glTexCoord3f( +1, -1, -1 ); glVertex3f( -D, +H, +D );
glTexCoord3f( -1, -1, -1 ); glVertex3f( +D, +H, +D );
glTexCoord3f( -1, -1, +1 ); glVertex3f( +D, +H, -D );
// GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
glTexCoord3f( -1, +1, +1 ); glVertex3f( +D, FH, -D );
glTexCoord3f( +1, +1, +1 ); glVertex3f( -D, FH, -D );
@ -320,7 +320,7 @@ void SkyManager::RenderSky()
glDisable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_2D);
}
glPopMatrix();
glDepthMask( GL_TRUE );

View File

@ -177,7 +177,7 @@ void TerrainOverlay::RenderTile(const CColor& color, bool draw_hidden, ssize_t i
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
}
#if CONFIG2_GLES
#warning TODO: implement TerrainOverlay::RenderTile for GLES
#else

View File

@ -198,7 +198,7 @@ void TerrainRenderer::RenderTerrain(int cullGroup)
// switch on required client states
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// render everything fullbright
// set up texture environment for base pass
pglActiveTextureARB(GL_TEXTURE0);
@ -214,7 +214,7 @@ void TerrainRenderer::RenderTerrain(int cullGroup)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
static const float one[4] = { 1.f, 1.f, 1.f, 1.f };
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, one);
PROFILE_START("render terrain base");
CPatchRData::RenderBases(visiblePatches, CShaderDefines(), NULL, true, dummyShader);
PROFILE_END("render terrain base");
@ -243,7 +243,7 @@ void TerrainRenderer::RenderTerrain(int cullGroup)
// no need to write to the depth buffer a second time
glDepthMask(0);
// The decal color array contains lighting data, which we don't want in this non-shader mode
glDisableClientState(GL_COLOR_ARRAY);
@ -471,7 +471,7 @@ void TerrainRenderer::PrepareShader(const CShaderProgramPtr& shader, ShadowMap*
shader->Uniform(str_ambient, lightEnv.m_TerrainAmbientColor);
shader->Uniform(str_sunColor, lightEnv.m_SunColor);
shader->Uniform(str_sunDir, lightEnv.GetSunDir());
shader->Uniform(str_fogColor, lightEnv.m_FogColor);
shader->Uniform(str_fogParams, lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f);
}
@ -630,10 +630,10 @@ CBoundingBoxAligned TerrainRenderer::ScissorWater(int cullGroup, const CMatrix3D
bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow)
{
PROFILE3_GPU("fancy water");
WaterManager* WaterMgr = g_Renderer.GetWaterManager();
CShaderDefines defines = context;
// If we're using fancy water, make sure its shader is loaded
if (!m->fancyWaterShader || WaterMgr->m_NeedsReloading)
{
@ -647,13 +647,13 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
defines.Add(str_USE_REFLECTION, str_1);
if (shadow && WaterMgr->m_WaterShadows)
defines.Add(str_USE_SHADOWS_ON_WATER, str_1);
// haven't updated the ARB shader yet so I'll always load the GLSL
/*if (!g_Renderer.m_Options.m_PreferGLSL && !superFancy)
m->fancyWaterShader = g_Renderer.GetShaderManager().LoadProgram("arb/water_high", defines);
else*/
m->fancyWaterShader = g_Renderer.GetShaderManager().LoadProgram("glsl/water_high", defines);
if (!m->fancyWaterShader)
{
LOGERROR("Failed to load water shader. Falling back to fixed pipeline water.\n");
@ -662,7 +662,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
}
WaterMgr->m_NeedsReloading = false;
}
CLOSTexture& losTexture = g_Renderer.GetScene().GetLOSTexture();
// creating the real depth texture using the depth buffer.
@ -693,32 +693,32 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
WaterMgr->m_NeedInfoUpdate = false;
WaterMgr->CreateSuperfancyInfo();
}*/
double time = WaterMgr->m_WaterTexTimer;
double period = 8;
int curTex = (int)(time*60/period) % 60;
int nexTex = (curTex + 1) % 60;
float repeatPeriod = WaterMgr->m_RepeatPeriod;
// Render normals and foam to a framebuffer if we're in fancy effects
if (WaterMgr->m_WaterFancyEffects)
{
// Save the post-processing framebuffer.
GLint fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, WaterMgr->m_FancyEffectsFBO);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDisable(GL_CULL_FACE);
// Overwrite waves that would be behind the ground.
CShaderProgramPtr dummyShader = g_Renderer.GetShaderManager().LoadProgram("glsl/gui_solid", CShaderDefines());
dummyShader->Bind();
dummyShader->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
dummyShader->Uniform(str_color, 0.0f, 0.0f, 0.0f, 0.0f);
std::vector<CPatchRData*>& visiblePatches = m->visiblePatches[cullGroup];
@ -728,7 +728,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
data->RenderWater(dummyShader, true, true);
}
dummyShader->Unbind();
glEnable(GL_CULL_FACE);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
}
@ -736,24 +736,24 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
m->fancyWaterShader->Bind();
const CCamera& camera = g_Renderer.GetViewCamera();
CVector3D camPos = camera.m_Orientation.GetTranslation();
m->fancyWaterShader->BindTexture(str_normalMap, WaterMgr->m_NormalMap[curTex]);
m->fancyWaterShader->BindTexture(str_normalMap2, WaterMgr->m_NormalMap[nexTex]);
if (WaterMgr->m_WaterFancyEffects)
{
m->fancyWaterShader->BindTexture(str_waterEffectsTexNorm, WaterMgr->m_FancyTextureNormal);
m->fancyWaterShader->BindTexture(str_waterEffectsTexOther, WaterMgr->m_FancyTextureOther);
}
if (WaterMgr->m_WaterRealDepth)
m->fancyWaterShader->BindTexture(str_depthTex, WaterMgr->m_depthTT);
if (WaterMgr->m_WaterRefraction)
m->fancyWaterShader->BindTexture(str_refractionMap, WaterMgr->m_RefractionTexture);
if (WaterMgr->m_WaterReflection)
@ -791,7 +791,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
m->fancyWaterShader->Uniform(str_fogParams, lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f);
m->fancyWaterShader->Uniform(str_time, (float)time);
m->fancyWaterShader->Uniform(str_screenSize, (float)g_Renderer.GetWidth(), (float)g_Renderer.GetHeight(), 0.0f, 0.0f);
if (WaterMgr->m_WaterType == L"clap")
{
m->fancyWaterShader->Uniform(str_waveParams1, 30.0f,1.5f,20.0f,0.03f);
@ -807,7 +807,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
m->fancyWaterShader->Uniform(str_waveParams1, 15.0f,0.8f,10.0f,0.1f);
m->fancyWaterShader->Uniform(str_waveParams2, 0.3f,0.0f,0.1f,0.3f);
}
if (shadow && WaterMgr->m_WaterShadows)
{
m->fancyWaterShader->BindTexture(str_shadowTex, shadow->GetTexture());

View File

@ -35,7 +35,7 @@ VertexArray::VertexArray(GLenum usage, GLenum target)
m_Usage = usage;
m_Target = target;
m_NumVertices = 0;
m_VB = 0;
m_BackingStore = 0;
m_Stride = 0;
@ -52,7 +52,7 @@ void VertexArray::Free()
{
rtl_FreeAligned(m_BackingStore);
m_BackingStore = 0;
if (m_VB)
{
g_VBMan.Release(m_VB);
@ -66,7 +66,7 @@ void VertexArray::SetNumVertices(size_t num)
{
if (num == m_NumVertices)
return;
Free();
m_NumVertices = num;
}
@ -83,7 +83,7 @@ void VertexArray::AddAttribute(Attribute* attr)
attr->vertexArray = this;
m_Attributes.push_back(attr);
Free();
}
@ -97,7 +97,7 @@ VertexArrayIterator<CVector3D> VertexArray::Attribute::GetIterator<CVector3D>()
ENSURE(vertexArray);
ENSURE(type == GL_FLOAT);
ENSURE(elems >= 3);
return vertexArray->MakeIterator<CVector3D>(this);
}
@ -107,7 +107,7 @@ VertexArrayIterator<CVector4D> VertexArray::Attribute::GetIterator<CVector4D>()
ENSURE(vertexArray);
ENSURE(type == GL_FLOAT);
ENSURE(elems >= 4);
return vertexArray->MakeIterator<CVector4D>(this);
}
@ -117,7 +117,7 @@ VertexArrayIterator<float[2]> VertexArray::Attribute::GetIterator<float[2]>() co
ENSURE(vertexArray);
ENSURE(type == GL_FLOAT);
ENSURE(elems >= 2);
return vertexArray->MakeIterator<float[2]>(this);
}
@ -127,7 +127,7 @@ VertexArrayIterator<SColor3ub> VertexArray::Attribute::GetIterator<SColor3ub>()
ENSURE(vertexArray);
ENSURE(type == GL_UNSIGNED_BYTE);
ENSURE(elems >= 3);
return vertexArray->MakeIterator<SColor3ub>(this);
}
@ -137,7 +137,7 @@ VertexArrayIterator<SColor4ub> VertexArray::Attribute::GetIterator<SColor4ub>()
ENSURE(vertexArray);
ENSURE(type == GL_UNSIGNED_BYTE);
ENSURE(elems >= 4);
return vertexArray->MakeIterator<SColor4ub>(this);
}
@ -211,7 +211,7 @@ static size_t RoundStride(size_t stride)
return 8;
if (stride <= 16)
return 16;
return Align<32>(stride);
}
@ -221,18 +221,18 @@ static size_t RoundStride(size_t stride)
void VertexArray::Layout()
{
Free();
m_Stride = 0;
//debug_printf("Layouting VertexArray\n");
for (ssize_t idx = m_Attributes.size()-1; idx >= 0; --idx)
{
Attribute* attr = m_Attributes[idx];
if (!attr->type || !attr->elems)
continue;
size_t attrSize = 0;
switch(attr->type)
{
@ -254,7 +254,7 @@ void VertexArray::Layout()
}
attrSize *= attr->elems;
attr->offset = m_Stride;
m_Stride += attrSize;
@ -264,12 +264,12 @@ void VertexArray::Layout()
//debug_printf("%i: offset: %u\n", idx, attr->offset);
}
if (m_Target == GL_ARRAY_BUFFER)
m_Stride = RoundStride(m_Stride);
//debug_printf("Stride: %u\n", m_Stride);
if (m_Stride)
m_BackingStore = (char*)rtl_AllocateAligned(m_Stride * m_NumVertices, 16);
}
@ -284,7 +284,7 @@ void VertexArray::PrepareForRendering()
void VertexArray::Upload()
{
ENSURE(m_BackingStore);
if (!m_VB)
m_VB = g_VBMan.Allocate(m_Stride, m_NumVertices, m_Usage, m_Target, m_BackingStore);

View File

@ -149,7 +149,7 @@ CVertexBuffer::VBChunk* CVertexBuffer::Allocate(size_t vertexSize, size_t numVer
// resize given chunk
chunk->m_Count = numVertices;
}
// return found chunk
m_AllocList.push_back(chunk);
return chunk;

View File

@ -87,7 +87,7 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize, size_t
CVertexBuffer* buffer = new CVertexBuffer(vertexSize, usage, target);
m_Buffers.push_front(buffer);
result = buffer->Allocate(vertexSize, numVertices, usage, target, backingStore);
if (!result)
{
LOGERROR("Failed to create VBOs (%lu*%lu)", (unsigned long)vertexSize, (unsigned long)numVertices);

View File

@ -88,15 +88,15 @@ WaterManager::WaterManager()
m_WaterHeight = 5.0f;
m_WaterCurrentTex = 0;
m_ReflectionTexture = 0;
m_RefractionTexture = 0;
m_RefTextureSize = 0;
m_ReflectionFbo = 0;
m_RefractionFbo = 0;
m_FancyEffectsFBO = 0;
m_WaterTexTimer = 0.0;
m_WindAngle = 0.0f;
@ -111,7 +111,7 @@ WaterManager::WaterManager()
m_WindStrength = NULL;
m_ShoreWaves_VBIndices = NULL;
m_WaterUgly = false;
m_WaterFancyEffects = false;
m_WaterRealDepth = false;
@ -119,10 +119,10 @@ WaterManager::WaterManager()
m_WaterReflection = false;
m_WaterShadows = false;
m_WaterType = L"ocean";
m_NeedsReloading = false;
m_NeedInfoUpdate = true;
m_depthTT = 0;
m_FancyTextureNormal = 0;
m_FancyTextureOther = 0;
@ -131,7 +131,7 @@ WaterManager::WaterManager()
m_RefrFboDepthTexture = 0;
m_MapSize = 0;
m_updatei0 = 0;
m_updatej0 = 0;
m_updatei1 = 0;
@ -156,7 +156,7 @@ WaterManager::~WaterManager()
delete[] m_DistanceHeightmap;
delete[] m_BlurredNormalMap;
delete[] m_WindStrength;
if (!g_Renderer.GetCapabilities().m_PrettyWater)
return;
@ -166,7 +166,7 @@ WaterManager::~WaterManager()
glDeleteTextures(1, &m_FancyTextureDepth);
glDeleteTextures(1, &m_ReflFboDepthTexture);
glDeleteTextures(1, &m_RefrFboDepthTexture);
pglDeleteFramebuffersEXT(1, &m_FancyEffectsFBO);
pglDeleteFramebuffersEXT(1, &m_RefractionFbo);
pglDeleteFramebuffersEXT(1, &m_ReflectionFbo);
@ -181,7 +181,7 @@ int WaterManager::LoadWaterTextures()
// (since texture loading is async now)
wchar_t pathname[PATH_MAX];
// Load diffuse grayscale images (for non-fancy water)
for (size_t i = 0; i < ARRAY_SIZE(m_WaterTexture); ++i)
{
@ -211,12 +211,12 @@ int WaterManager::LoadWaterTextures()
CTextureProperties textureProps(pathname);
textureProps.SetWrap(GL_REPEAT);
textureProps.SetMaxAnisotropy(4);
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
texture->Prefetch();
m_NormalMap[i] = texture;
}
// Load CoastalWaves
{
CTextureProperties textureProps(L"art/textures/terrain/types/water/coastalWave.png");
@ -225,7 +225,7 @@ int WaterManager::LoadWaterTextures()
texture->Prefetch();
m_WaveTex = texture;
}
// Load Foam
{
CTextureProperties textureProps(L"art/textures/terrain/types/water/foam.png");
@ -234,12 +234,12 @@ int WaterManager::LoadWaterTextures()
texture->Prefetch();
m_FoamTex = texture;
}
// Use screen-sized textures for minimum artifacts.
m_RefTextureSize = g_Renderer.GetHeight();
m_RefTextureSize = round_up_to_pow2(m_RefTextureSize);
// Create reflection texture
glGenTextures(1, &m_ReflectionTexture);
glBindTexture(GL_TEXTURE_2D, m_ReflectionTexture);
@ -248,7 +248,7 @@ int WaterManager::LoadWaterTextures()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Create refraction texture
glGenTextures(1, &m_RefractionTexture);
glBindTexture(GL_TEXTURE_2D, m_RefractionTexture);
@ -266,7 +266,7 @@ int WaterManager::LoadWaterTextures()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
glGenTextures(1, &m_RefrFboDepthTexture);
glBindTexture(GL_TEXTURE_2D, m_RefrFboDepthTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@ -313,7 +313,7 @@ int WaterManager::LoadWaterTextures()
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_ReflFboDepthTexture, 0);
ogl_WarnIfError();
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
@ -328,29 +328,29 @@ int WaterManager::LoadWaterTextures()
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_RefrFboDepthTexture, 0);
ogl_WarnIfError();
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Refraction framebuffer object incomplete: 0x%04X", status);
g_Renderer.m_Options.m_WaterRefraction = false;
}
pglGenFramebuffersEXT(1, &m_FancyEffectsFBO);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FancyTextureNormal, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, m_FancyTextureOther, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_FancyTextureDepth, 0);
ogl_WarnIfError();
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Fancy Effects framebuffer object incomplete: 0x%04X", status);
g_Renderer.m_Options.m_WaterRefraction = false;
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFbo);
// Enable rendering, now that we've succeeded this far
@ -387,7 +387,7 @@ void WaterManager::ReloadWaterNormalTextures()
CTextureProperties textureProps(pathname);
textureProps.SetWrap(GL_REPEAT);
textureProps.SetMaxAnisotropy(4);
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
texture->Prefetch();
m_NormalMap[i] = texture;
@ -420,13 +420,13 @@ void WaterManager::RecomputeDistanceHeightmap()
size_t SideSize = m_MapSize*2;
if (m_DistanceHeightmap == NULL)
m_DistanceHeightmap = new float[SideSize*SideSize];
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
// Create a manhattan-distance heightmap.
// This is currently upsampled by a factor of 2 to get more precision
// This could be refined to only be done near the coast itself, but it's probably not necessary.
for (size_t z = 0; z < SideSize; ++z)
{
float level = SideSize;
@ -500,14 +500,14 @@ void WaterManager::CreateWaveMeshes()
if (m_Waviness < 5.0f && m_WaterType != L"ocean")
return;
// First step: get the points near the coast.
std::set<int> CoastalPointsSet;
for (size_t z = 1; z < SideSize-1; ++z)
for (size_t x = 1; x < SideSize-1; ++x)
if (fabs(m_DistanceHeightmap[z*SideSize + x]-1.0f) < 0.2f)
CoastalPointsSet.insert(z*SideSize + x);
// Second step: create chains out of those coastal points.
static const int around[8][2] = { { -1,-1 }, { -1,0 }, { -1,1 }, { 0,1 }, { 1,1 }, { 1,0 }, { 1,-1 }, { 0,-1 } };
@ -517,14 +517,14 @@ void WaterManager::CreateWaveMeshes()
int index = *(CoastalPointsSet.begin());
int x = index % SideSize;
int y = (index - x ) / SideSize;
std::deque<CoastalPoint> Chain;
Chain.push_front(CoastalPoint(index,CVector2D(x*2,y*2)));
// Erase us.
CoastalPointsSet.erase(CoastalPointsSet.begin());
// We're our starter points. At most we can have 2 points close to us.
// We'll pick the first one and look for its neighbors (he can only have one new)
// Up until we either reach the end of the chain, or ourselves.
@ -552,7 +552,7 @@ void WaterManager::CreateWaveMeshes()
int yy = (neighbours[i] - xx ) / SideSize;
int indexx = xx + yy*SideSize;
int endedChain = false;
if (i == 0)
Chain.push_back(CoastalPoint(indexx,CVector2D(xx*2,yy*2)));
else
@ -562,7 +562,7 @@ void WaterManager::CreateWaveMeshes()
// We'll readd at the end/front the other one to have full squares.
if (CoastalPointsSet.count(indexx) == 0)
break;
CoastalPointsSet.erase(indexx);
// Start checking from there.
@ -601,7 +601,7 @@ void WaterManager::CreateWaveMeshes()
if (Chain.size() > 10)
CoastalPointsChains.push_back(Chain);
}
// (optional) third step: Smooth chains out.
// This is also really dumb.
for (size_t i = 0; i < CoastalPointsChains.size(); ++i)
@ -612,15 +612,15 @@ void WaterManager::CreateWaveMeshes()
for (size_t j = 1; j < CoastalPointsChains[i].size()-1; ++j)
{
CVector2D realPos = CoastalPointsChains[i][j-1].position + CoastalPointsChains[i][j+1].position;
CoastalPointsChains[i][j].position = (CoastalPointsChains[i][j].position + realPos/2.0f)/2.0f;
}
}
}
// Fourth step: create waves themselves, using those chains. We basically create subchains.
size_t waveSizes = 14; // maximal size in width.
// Construct indices buffer (we can afford one for all of them)
std::vector<GLushort> water_indices;
for (size_t a = 0; a < waveSizes-1;++a)
@ -638,18 +638,18 @@ void WaterManager::CreateWaveMeshes()
// Generic indexes, max-length
m_ShoreWaves_VBIndices = g_VBMan.Allocate(sizeof(GLushort), water_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
m_ShoreWaves_VBIndices->m_Owner->UpdateChunkVertices(m_ShoreWaves_VBIndices, &water_indices[0]);
float diff = (rand() % 50) / 5.0f;
for (size_t i = 0; i < CoastalPointsChains.size(); ++i)
{
for (size_t j = 0; j < CoastalPointsChains[i].size()-waveSizes; ++j)
{
if (CoastalPointsChains[i].size()- 1 - j < waveSizes)
break;
size_t width = waveSizes;
// First pass to get some parameters out.
float outmost = 0.0f; // how far to move on the shore.
float avgDepth = 0.0f;
@ -677,27 +677,27 @@ void WaterManager::CreateWaveMeshes()
}
perp /= nb;
perp = CVector2D(-perp.Y,perp.X).Normalized();
if (a == 0)
firstPerp = perp;
if ( a > 1 && perp.Dot(lastPerp) < 0.90f && perp.Dot(firstPerp) < 0.70f)
{
width = a+1;
break;
}
if (m_BlurredNormalMap[ (int)(pos.X/4) + (int)(pos.Y/4)*m_MapSize].Y < 0.9)
{
width = a-1;
break;
}
if (terrain->GetExactGroundLevel(pos.X+perp.X*1.5f, pos.Y+perp.Y*1.5f) > m_WaterHeight)
sign = -1;
avgDepth += terrain->GetExactGroundLevel(pos.X+sign*perp.X*20.0f, pos.Y+sign*perp.Y*20.0f) - m_WaterHeight;
float localOutmost = -2.0f;
while (localOutmost < 0.0f)
{
@ -717,7 +717,7 @@ void WaterManager::CreateWaveMeshes()
}
outmost /= width;
if (outmost > -0.5f)
{
j += 3;
@ -733,7 +733,7 @@ void WaterManager::CreateWaveMeshes()
continue;
}
// we passed the checks, we can create a wave of size "width".
WaveObject* shoreWave = new WaveObject;
std::vector<SWavesVertex> vertices;
@ -762,14 +762,14 @@ void WaterManager::CreateWaveMeshes()
}
perp /= nb;
perp = CVector2D(-perp.Y,perp.X).Normalized();
SWavesVertex point[9];
float baseHeight = 0.04f;
float halfWidth = (width-1.0f)/2.0f;
float sideNess = sqrtf(clamp( (halfWidth - fabsf(a-halfWidth))/3.0f, 0.0f,1.0f));
point[0].m_UV[0] = a; point[0].m_UV[1] = 8;
point[1].m_UV[0] = a; point[1].m_UV[1] = 7;
point[2].m_UV[0] = a; point[2].m_UV[1] = 6;
@ -779,7 +779,7 @@ void WaterManager::CreateWaveMeshes()
point[6].m_UV[0] = a; point[6].m_UV[1] = 2;
point[7].m_UV[0] = a; point[7].m_UV[1] = 1;
point[8].m_UV[0] = a; point[8].m_UV[1] = 0;
point[0].m_PerpVect = perp;
point[1].m_PerpVect = perp;
point[2].m_PerpVect = perp;
@ -789,12 +789,12 @@ void WaterManager::CreateWaveMeshes()
point[6].m_PerpVect = perp;
point[7].m_PerpVect = perp;
point[8].m_PerpVect = perp;
static const float perpT1[9] = { 6.0f, 6.05f, 6.1f, 6.2f, 6.3f, 6.4f, 6.5f, 6.6f, 9.7f };
static const float perpT2[9] = { 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 3.0f, 3.3f, 3.6f, 9.5f };
static const float perpT3[9] = { 1.1f, 0.7f, -0.2f, 0.0f, 0.6f, 1.3f, 2.2f, 3.6f, 9.0f };
static const float perpT4[9] = { 2.0f, 2.1f, 1.2f, 1.5f, 1.7f, 1.9f, 2.7f, 3.8f, 9.0f };
static const float heightT1[9] = { 0.0f, 0.2f, 0.5f, 0.8f, 0.9f, 0.85f, 0.6f, 0.2f, 0.0 };
static const float heightT2[9] = { -0.8f, -0.4f, 0.0f, 0.1f, 0.1f, 0.03f, 0.0f, 0.0f, 0.0 };
static const float heightT3[9] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0 };
@ -826,7 +826,7 @@ void WaterManager::CreateWaveMeshes()
point[t].m_RetreatPosition = CVector3D(pos.X+sign*perp.X*(perpT4[t]+outmost), baseHeight + heightT3[t]*sideNess + std::max(m_WaterHeight,terrHeight),
pos.Y+sign*perp.Y*(perpT4[t]+outmost));
}
vertices.push_back(point[8]);
vertices.push_back(point[7]);
vertices.push_back(point[6]);
@ -836,7 +836,7 @@ void WaterManager::CreateWaveMeshes()
vertices.push_back(point[2]);
vertices.push_back(point[1]);
vertices.push_back(point[0]);
shoreWave->m_AABB += point[8].m_SplashPosition;
shoreWave->m_AABB += point[8].m_BasePosition;
shoreWave->m_AABB += point[0].m_SplashPosition;
@ -856,10 +856,10 @@ void WaterManager::CreateWaveMeshes()
vertices = reversed;
}
j += width/2-1;
shoreWave->m_VBvertices = g_VBMan.Allocate(sizeof(SWavesVertex), vertices.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER);
shoreWave->m_VBvertices->m_Owner->UpdateChunkVertices(shoreWave->m_VBvertices, &vertices[0]);
m_ShoreWaves.push_back(shoreWave);
}
}
@ -872,28 +872,28 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
#else
if (g_Renderer.m_SkipSubmit || !m_WaterFancyEffects)
return;
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
pglDrawBuffers(2, attachments);
glClearColor(0.0f,0.0f, 0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
CShaderDefines none;
CShaderProgramPtr shad = g_Renderer.GetShaderManager().LoadProgram("glsl/waves", none);
shad->Bind();
shad->BindTexture(str_waveTex, m_WaveTex);
shad->BindTexture(str_foamTex, m_FoamTex);
shad->Uniform(str_time, (float)m_WaterTexTimer);
shad->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
@ -901,10 +901,10 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
{
if (!frustrum.IsBoxVisible(m_ShoreWaves[a]->m_AABB))
continue;
CVertexBuffer::VBChunk* VBchunk = m_ShoreWaves[a]->m_VBvertices;
SWavesVertex* base = (SWavesVertex*)VBchunk->m_Owner->Bind();
// setup data pointers
GLsizei stride = sizeof(SWavesVertex);
shad->VertexPointer(3, GL_FLOAT, stride, &base[VBchunk->m_Index].m_BasePosition);
@ -914,22 +914,22 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
shad->VertexAttribPointer(str_a_apexPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_ApexPosition);
shad->VertexAttribPointer(str_a_splashPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_SplashPosition);
shad->VertexAttribPointer(str_a_retreatPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_RetreatPosition);
shad->AssertPointersBound();
shad->Uniform(str_translation, m_ShoreWaves[a]->m_TimeDiff);
shad->Uniform(str_width, (int)m_ShoreWaves[a]->m_Width);
u8* indexBase = m_ShoreWaves_VBIndices->m_Owner->Bind();
glDrawElements(GL_TRIANGLES, (GLsizei) (m_ShoreWaves[a]->m_Width-1)*(7*6),
GL_UNSIGNED_SHORT, indexBase + sizeof(u16)*(m_ShoreWaves_VBIndices->m_Index));
shad->Uniform(str_translation, m_ShoreWaves[a]->m_TimeDiff + 6.0f);
// TODO: figure out why this doesn't work.
//g_Renderer.m_Stats.m_DrawCalls++;
//g_Renderer.m_Stats.m_WaterTris += m_ShoreWaves_VBIndices->m_Count / 3;
CVertexBuffer::Unbind();
}
shad->Unbind();
@ -950,10 +950,10 @@ void WaterManager::RecomputeBlurredNormalMap()
m_BlurredNormalMap = new CVector3D[m_MapSize*m_MapSize];
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
// It's really slow to calculate normals so cache them first.
CVector3D* normals = new CVector3D[m_MapSize*m_MapSize];
// Not the edges, we won't care about them.
float ii = 8.0f, jj = 8.0f;
for (size_t j = 2; j < m_MapSize-2; ++j, jj += 4.0f)
@ -963,7 +963,7 @@ void WaterManager::RecomputeBlurredNormalMap()
terrain->CalcNormal(i,j,norm);
normals[j*m_MapSize + i] = norm;
}
// We could be way fancier (and faster) for our blur but we probably don't need the complexity.
// Two pass filter, nothing complicated here.
CVector3D blurValue;
@ -993,7 +993,7 @@ void WaterManager::RecomputeBlurredNormalMap()
m_BlurredNormalMap[j*m_MapSize + i] = blurValue * 0.2f;
}
}
delete[] normals;
}
@ -1004,16 +1004,16 @@ void WaterManager::RecomputeWindStrength()
{
if (m_WindStrength == NULL)
m_WindStrength = new float[m_MapSize*m_MapSize];
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
float waterLevel = m_WaterHeight;
CVector2D windDir = CVector2D(cos(m_WindAngle),sin(m_WindAngle));
CVector2D perp = CVector2D(-windDir.Y, windDir.X);
// Our kernel will sample 5 points going towards the wind (generally).
int kernel[5][2] = { {(int)windDir.X*2,(int)windDir.Y*2}, {(int)windDir.X*5,(int)windDir.Y*5}, {(int)windDir.X*9,(int)windDir.Y*9}, {(int)windDir.X*16,(int)windDir.Y*16}, {(int)windDir.X*25,(int)windDir.Y*25} };
float* Temp = new float[m_MapSize*m_MapSize];
std::fill(Temp, Temp + m_MapSize*m_MapSize, 1.0f);
@ -1028,7 +1028,7 @@ void WaterManager::RecomputeWindStrength()
}
if (terrain->GetVertexGroundLevel(i + ceil(windDir.X),j + ceil(windDir.Y)) < waterLevel)
continue;
// Calculate how dampened our waves should be.
float tendency = 0.0f;
float oldHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[4][0],j+kernel[4][1]));
@ -1047,13 +1047,13 @@ void WaterManager::RecomputeWindStrength()
currentHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[0][0],j+kernel[0][1]));
avgheight += currentHeight;
tendency += currentHeight - oldHeight;
float baseLevel = std::max(0.0f,1.0f - (avgheight/5.0f-waterLevel)/20.0f);
baseLevel *= baseLevel;
tendency /= 15.0f;
baseLevel -= tendency; // if the terrain was sloping downwards, increase baselevel. Otherwise reduce.
baseLevel = clamp(baseLevel,0.0f,1.0f);
// Draw on map. This is pretty slow.
float length = 35.0f * (1.0f-baseLevel/1.8f);
for (float y = 0; y < length; y += 0.6f)
@ -1064,7 +1064,7 @@ void WaterManager::RecomputeWindStrength()
Temp[yy*m_MapSize + xx] : (0.0f+baseLevel/1.5f) * (1.0f-y/length) + y/length * 1.0f;
}
}
int blurKernel[4][2] = { {(int)ceil(windDir.X),(int)ceil(windDir.Y)}, {(int)windDir.X*3,(int)windDir.Y*3}, {(int)ceil(perp.X),(int)ceil(perp.Y)}, {(int)-ceil(perp.X),(int)-ceil(perp.Y)} };
float blurValue;
for (size_t j = 2; j < m_MapSize-2; ++j)
@ -1090,7 +1090,7 @@ void WaterManager::SetMapSize(size_t size)
m_updatei1 = size;
m_updatej0 = 0;
m_updatej1 = size;
SAFE_ARRAY_DELETE(m_DistanceHeightmap);
SAFE_ARRAY_DELETE(m_BlurredNormalMap);
SAFE_ARRAY_DELETE(m_WindStrength);

View File

@ -405,7 +405,7 @@ template<typename T> static bool FromJSVal_vector(JSContext* cx, JS::HandleValue
obj = &v.toObject();
if (!(JS_IsArrayObject(cx, obj) || JS_IsTypedArrayObject(obj)))
FAIL("Argument must be an array");
u32 length;
if (!JS_GetArrayLength(cx, obj, &length))
FAIL("Failed to get array length");

View File

@ -409,7 +409,7 @@ ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugN
if (g_ScriptStatsTable)
g_ScriptStatsTable->Add(this, debugName);
}
m_CxPrivate.pScriptInterface = this;
JS_SetContextPrivate(m->m_cx, (void*)&m_CxPrivate);
}
@ -575,7 +575,7 @@ bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::H
JS::RootedObject obj(m->m_cx);
if (!JS_ValueToObject(m->m_cx, val, &obj) || !obj)
return false;
// Check that the named function actually exists, to avoid ugly JS error reports
// when calling an undefined value
bool found;
@ -708,7 +708,7 @@ bool ScriptInterface::GetProperty_(JS::HandleValue obj, const char* name, JS::Mu
if (!obj.isObject())
return false;
JS::RootedObject object(m->m_cx, &obj.toObject());
if (!JS_GetProperty(m->m_cx, object, name, out))
return false;
return true;
@ -721,7 +721,7 @@ bool ScriptInterface::GetPropertyInt_(JS::HandleValue obj, int name, JS::Mutable
if (!obj.isObject())
return false;
JS::RootedObject object(m->m_cx, &obj.toObject());
if (!JS_GetPropertyById(m->m_cx, object, nameId, out))
return false;
return true;
@ -744,16 +744,16 @@ bool ScriptInterface::HasProperty(JS::HandleValue obj, const char* name)
bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, const char* prefix, std::vector<std::string>& out)
{
JSAutoRequest rq(m->m_cx);
if (!objVal.isObjectOrNull())
{
LOGERROR("EnumeratePropertyNamesWithPrefix expected object type!");
return false;
}
if (objVal.isNull())
return true; // reached the end of the prototype chain
JS::RootedObject obj(m->m_cx, &objVal.toObject());
JS::AutoIdArray props(m->m_cx, JS_Enumerate(m->m_cx, obj));
if (!props)
@ -823,7 +823,7 @@ bool ScriptInterface::FreezeObject(JS::HandleValue objVal, bool deep)
JSAutoRequest rq(m->m_cx);
if (!objVal.isObject())
return false;
JS::RootedObject obj(m->m_cx, &objVal.toObject());
if (deep)
@ -926,7 +926,7 @@ bool ScriptInterface::Eval_(const char* code, JS::MutableHandleValue rval)
JSAutoRequest rq(m->m_cx);
JS::RootedObject global(m->m_cx, m->m_glob);
utf16string codeUtf16(code, code+strlen(code));
JS::CompileOptions opts(m->m_cx);
opts.setFileAndLine("(eval)", 1);
return JS::Evaluate(m->m_cx, global, opts, reinterpret_cast<const char16_t*>(codeUtf16.c_str()), (uint)codeUtf16.length(), rval);

View File

@ -70,21 +70,21 @@ void GCSliceCallbackHook(JSRuntime* UNUSED(rt), JS::GCProgress progress, const J
const char16_t* str = desc.formatMessage(rt);
int len = 0;
for(int i = 0; i < 10000; i++)
{
len++;
if(!str[i])
break;
}
wchar_t outstring[len];
for(int i = 0; i < len; i++)
{
outstring[i] = (wchar_t)str[i];
}
printf("---------------------------------------\n: %ls \n---------------------------------------\n", outstring);
#endif
}
@ -155,7 +155,7 @@ void ScriptRuntime::UnRegisterContext(JSContext* cx)
void ScriptRuntime::MaybeIncrementalGC(double delay)
{
PROFILE2("MaybeIncrementalGC");
if (JS::IsIncrementalGCEnabled(m_rt))
{
// The idea is to get the heap size after a completed GC and trigger the next GC when the heap size has
@ -165,22 +165,22 @@ void ScriptRuntime::MaybeIncrementalGC(double delay)
// While the sweeping is happening we already run scripts again and produce new garbage.
const int GCSliceTimeBudget = 30; // Milliseconds an incremental slice is allowed to run
// Have a minimum time in seconds to wait between GC slices and before starting a new GC to distribute the GC
// load and to hopefully make it unnoticeable for the player. This value should be high enough to distribute
// the load well enough and low enough to make sure we don't run out of memory before we can start with the
// sweeping.
if (timer_Time() - m_LastGCCheck < delay)
return;
m_LastGCCheck = timer_Time();
int gcBytes = JS_GetGCParameter(m_rt, JSGC_BYTES);
#if GC_DEBUG_PRINT
std::cout << "gcBytes: " << gcBytes / 1024 << " KB" << std::endl;
#endif
if (m_LastGCBytes > gcBytes || m_LastGCBytes == 0)
{
#if GC_DEBUG_PRINT
@ -193,7 +193,7 @@ void ScriptRuntime::MaybeIncrementalGC(double delay)
// ... or
// start a new incremental GC if the JS heap size has grown enough for a GC to make sense
if (JS::IsIncrementalGCInProgress(m_rt) || (gcBytes - m_LastGCBytes > m_HeapGrowthBytesGCTrigger))
{
{
#if GC_DEBUG_PRINT
if (JS::IsIncrementalGCInProgress(m_rt))
printf("An incremental GC cycle is in progress. \n");
@ -204,7 +204,7 @@ void ScriptRuntime::MaybeIncrementalGC(double delay)
m_LastGCBytes / 1024,
m_HeapGrowthBytesGCTrigger / 1024);
#endif
// A hack to make sure we never exceed the runtime size because we can't collect the memory
// fast enough.
if (gcBytes > m_RuntimeSize / 2)

View File

@ -281,14 +281,14 @@ public:
{
for (size_t i=0; i<m_Players.size(); i++)
{
if (m_Players[i]->m_Player == playerid)
if (m_Players[i]->m_Player == playerid)
{
m_Players[i]->m_Commands.push_back(m_ScriptInterface->WriteStructuredClone(cmd));
return;
}
}
LOGERROR("Invalid playerid in PostCommand!");
LOGERROR("Invalid playerid in PostCommand!");
}
static JS::Value ComputePath(ScriptInterface::CxPrivate* pCxPrivate,
@ -539,7 +539,7 @@ public:
JS::AutoCheckCannotGC nogc;
memcpy((void*)JS_GetUint16ArrayData(dataObj, nogc), m_PassabilityMap.m_Data, nbytes);
}
}
}
void UpdateTerritoryMap(const Grid<u8>& territoryMap)
@ -548,7 +548,7 @@ public:
bool dimensionChange = m_TerritoryMap.m_W != territoryMap.m_W || m_TerritoryMap.m_H != territoryMap.m_H;
m_TerritoryMap = territoryMap;
JSContext* cx = m_ScriptInterface->GetContext();
if (dimensionChange)
ScriptInterface::ToJSVal(cx, &m_TerritoryMapVal, m_TerritoryMap);

View File

@ -66,7 +66,7 @@ public:
{
JSContext* cx = GetSimContext().GetScriptInterface().GetContext();
JSAutoRequest rq(cx);
u32 numCmds;
deserialize.NumberU32_Unbounded("num commands", numCmds);
for (size_t i = 0; i < numCmds; ++i)
@ -91,7 +91,7 @@ public:
{
JSContext* cx = GetSimContext().GetScriptInterface().GetContext();
JSAutoRequest rq(cx);
// TODO: This is a workaround because we need to pass a MutableHandle to StringifyJSON.
JS::RootedValue cmd(cx, cmd1.get());
@ -108,7 +108,7 @@ public:
ScriptInterface& scriptInterface = GetSimContext().GetScriptInterface();
JSContext* cx = scriptInterface.GetContext();
JSAutoRequest rq(cx);
JS::RootedValue global(cx, scriptInterface.GetGlobalObject());
std::vector<SimulationCommand> localCommands;
m_LocalQueue.swap(localCommands);

View File

@ -200,12 +200,12 @@ public:
entity_pos_t RotX = entity_pos_t::FromFloat(((m_InitialXRotation.ToFloat() * (5.f - tiltSink)) + (m_SinkingAngleX * tiltSink)) / 5.f);
entity_pos_t RotZ = entity_pos_t::FromFloat(((m_InitialZRotation.ToFloat() * (3.f - tilt_time)) + (m_SinkingAngleZ * tilt_time)) / 3.f);
cmpPosition->SetXZRotation(RotX,RotZ);
depth = m_SinkRate * (exp(t - 1.f) - 0.54881163609f) + (m_SinkAccel * exp(t - 4.f) - 0.01831563888f);
if (depth < 0.f)
depth = 0.f;
}
cmpPosition->SetHeightOffset(entity_pos_t::FromFloat(-depth));
if (depth > m_TotalSinkDepth)

Some files were not shown because too many files have changed in this diff Show More