mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
-1 -> NO_VALUE and other formatting
This commit is contained in:
parent
4a6f30a152
commit
ebb20121ac
1 changed files with 26 additions and 25 deletions
|
@ -769,8 +769,8 @@ namespace TEN::Renderer
|
||||||
{
|
{
|
||||||
constexpr auto AMBIENT_LIGHT_COLOR = Vector4(0.5f, 0.5f, 0.5f, 1.0f);
|
constexpr auto AMBIENT_LIGHT_COLOR = Vector4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||||
|
|
||||||
UINT stride = sizeof(Vertex);
|
unsigned int stride = sizeof(Vertex);
|
||||||
UINT offset = 0;
|
unsigned int offset = 0;
|
||||||
|
|
||||||
auto screenRes = GetScreenResolution();
|
auto screenRes = GetScreenResolution();
|
||||||
auto factor = Vector2(
|
auto factor = Vector2(
|
||||||
|
@ -780,10 +780,10 @@ namespace TEN::Renderer
|
||||||
pos2D *= factor;
|
pos2D *= factor;
|
||||||
scale *= (factor.x > factor.y) ? factor.y : factor.x;
|
scale *= (factor.x > factor.y) ? factor.y : factor.x;
|
||||||
|
|
||||||
int index = g_Gui.ConvertObjectToInventoryItem(objectNumber);
|
int invObjectID = g_Gui.ConvertObjectToInventoryItem(objectNumber);
|
||||||
if (index != -1)
|
if (invObjectID != NO_VALUE)
|
||||||
{
|
{
|
||||||
const auto& invObject = InventoryObjectTable[index];
|
const auto& invObject = InventoryObjectTable[invObjectID];
|
||||||
|
|
||||||
pos2D.y += invObject.YOffset;
|
pos2D.y += invObject.YOffset;
|
||||||
orient += invObject.Orientation;
|
orient += invObject.Orientation;
|
||||||
|
@ -793,7 +793,7 @@ namespace TEN::Renderer
|
||||||
auto projMatrix = Matrix::CreateOrthographic(_screenWidth, _screenHeight, -BLOCK(1), BLOCK(1));
|
auto projMatrix = Matrix::CreateOrthographic(_screenWidth, _screenHeight, -BLOCK(1), BLOCK(1));
|
||||||
|
|
||||||
auto& moveableObject = _moveableObjects[objectNumber];
|
auto& moveableObject = _moveableObjects[objectNumber];
|
||||||
if (!moveableObject)
|
if (!moveableObject.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& object = Objects[objectNumber];
|
const auto& object = Objects[objectNumber];
|
||||||
|
@ -805,7 +805,7 @@ namespace TEN::Renderer
|
||||||
&g_Level.Frames[GetAnimData(object.animIndex).FramePtr],
|
&g_Level.Frames[GetAnimData(object.animIndex).FramePtr],
|
||||||
0.0f
|
0.0f
|
||||||
};
|
};
|
||||||
UpdateAnimation(nullptr, *moveableObject, frameData, 0xFFFFFFFF);
|
UpdateAnimation(nullptr, *moveableObject, frameData, UINT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pos = _viewportToolkit.Unproject(Vector3(pos2D.x, pos2D.y, 1.0f), projMatrix, viewMatrix, Matrix::Identity);
|
auto pos = _viewportToolkit.Unproject(Vector3(pos2D.x, pos2D.y, 1.0f), projMatrix, viewMatrix, Matrix::Identity);
|
||||||
|
@ -820,35 +820,37 @@ namespace TEN::Renderer
|
||||||
_shaders.Bind(Shader::Inventory);
|
_shaders.Bind(Shader::Inventory);
|
||||||
|
|
||||||
// Set matrices.
|
// Set matrices.
|
||||||
CCameraMatrixBuffer hudCamera;
|
auto hudCamera = CCameraMatrixBuffer{};
|
||||||
hudCamera.CamDirectionWS = -Vector4::UnitZ;
|
hudCamera.CamDirectionWS = -Vector4::UnitZ;
|
||||||
hudCamera.ViewProjection = viewMatrix * projMatrix;
|
hudCamera.ViewProjection = viewMatrix * projMatrix;
|
||||||
_cbCameraMatrices.UpdateData(hudCamera, _context.Get());
|
_cbCameraMatrices.UpdateData(hudCamera, _context.Get());
|
||||||
BindConstantBufferVS(ConstantBufferRegister::Camera, _cbCameraMatrices.get());
|
BindConstantBufferVS(ConstantBufferRegister::Camera, _cbCameraMatrices.get());
|
||||||
|
|
||||||
for (int n = 0; n < (*moveableObject).ObjectMeshes.size(); n++)
|
for (int i = 0; i < moveableObject->ObjectMeshes.size(); i++)
|
||||||
{
|
{
|
||||||
if (meshBits && !(meshBits & (1 << n)))
|
if (meshBits && !(meshBits & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto* mesh = (*moveableObject).ObjectMeshes[n];
|
|
||||||
|
|
||||||
// HACK: Rotate compass needle.
|
// HACK: Rotate compass needle.
|
||||||
if (objectNumber == ID_COMPASS_ITEM && n == 1)
|
if (objectNumber == ID_COMPASS_ITEM && i == 1)
|
||||||
(*moveableObject).LinearizedBones[n]->ExtraRotation = EulerAngles(0, g_Gui.CompassNeedleAngle - ANGLE(180.0f), 0).ToQuaternion();
|
moveableObject->LinearizedBones[i]->ExtraRotation = EulerAngles(0, g_Gui.CompassNeedleAngle - ANGLE(180.0f), 0).ToQuaternion();
|
||||||
|
|
||||||
// Construct world matrix.
|
// Construct world matrix.
|
||||||
auto tMatrix = Matrix::CreateTranslation(pos.x, pos.y, pos.z + BLOCK(1));
|
auto translationMatrix = Matrix::CreateTranslation(pos.x, pos.y, pos.z + BLOCK(1));
|
||||||
auto rotMatrix = orient.ToRotationMatrix();
|
auto rotMatrix = orient.ToRotationMatrix();
|
||||||
auto scaleMatrix = Matrix::CreateScale(scale);
|
auto scaleMatrix = Matrix::CreateScale(scale);
|
||||||
auto worldMatrix = scaleMatrix * rotMatrix * tMatrix;
|
auto worldMatrix = scaleMatrix * rotMatrix * translationMatrix;
|
||||||
|
|
||||||
if (object.animIndex != -1)
|
if (object.animIndex != NO_VALUE)
|
||||||
_stItem.World = (*moveableObject).AnimationTransforms[n] * worldMatrix;
|
{
|
||||||
|
_stItem.World = moveableObject->AnimationTransforms[i] * worldMatrix;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_stItem.World = (*moveableObject).BindPoseTransforms[n] * worldMatrix;
|
{
|
||||||
|
_stItem.World = moveableObject->BindPoseTransforms[i] * worldMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
_stItem.BoneLightModes[n] = (int)LightMode::Dynamic;
|
_stItem.BoneLightModes[i] = (int)LightMode::Dynamic;
|
||||||
_stItem.Color = Vector4::One;
|
_stItem.Color = Vector4::One;
|
||||||
_stItem.AmbientLight = AMBIENT_LIGHT_COLOR;
|
_stItem.AmbientLight = AMBIENT_LIGHT_COLOR;
|
||||||
|
|
||||||
|
@ -856,7 +858,8 @@ namespace TEN::Renderer
|
||||||
BindConstantBufferVS(ConstantBufferRegister::Item, _cbItem.get());
|
BindConstantBufferVS(ConstantBufferRegister::Item, _cbItem.get());
|
||||||
BindConstantBufferPS(ConstantBufferRegister::Item, _cbItem.get());
|
BindConstantBufferPS(ConstantBufferRegister::Item, _cbItem.get());
|
||||||
|
|
||||||
for (const auto& bucket : mesh->Buckets)
|
const auto& mesh = *moveableObject->ObjectMeshes[i];
|
||||||
|
for (const auto& bucket : mesh.Buckets)
|
||||||
{
|
{
|
||||||
if (bucket.NumVertices == 0)
|
if (bucket.NumVertices == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -869,11 +872,9 @@ namespace TEN::Renderer
|
||||||
BindTexture(TextureRegister::NormalMap, &std::get<1>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp);
|
BindTexture(TextureRegister::NormalMap, &std::get<1>(_moveablesTextures[bucket.Texture]), SamplerStateRegister::AnisotropicClamp);
|
||||||
|
|
||||||
if (bucket.BlendMode != BlendMode::Opaque)
|
if (bucket.BlendMode != BlendMode::Opaque)
|
||||||
Renderer::SetBlendMode(bucket.BlendMode, true);
|
SetBlendMode(bucket.BlendMode, true);
|
||||||
|
|
||||||
SetAlphaTest(
|
SetAlphaTest((bucket.BlendMode == BlendMode::AlphaTest) ? AlphaTestMode::GreatherThan : AlphaTestMode::None, ALPHA_TEST_THRESHOLD);
|
||||||
(bucket.BlendMode == BlendMode::AlphaTest) ? AlphaTestMode::GreatherThan : AlphaTestMode::None,
|
|
||||||
ALPHA_TEST_THRESHOLD);
|
|
||||||
|
|
||||||
DrawIndexedTriangles(bucket.NumIndices, bucket.StartIndex, 0);
|
DrawIndexedTriangles(bucket.NumIndices, bucket.StartIndex, 0);
|
||||||
_numMoveablesDrawCalls++;
|
_numMoveablesDrawCalls++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue