Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Model.cpp
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
historic_bruno: 2019 | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 22 Lines | |||||
#include "SkeletonAnimManager.h" | #include "SkeletonAnimManager.h" | ||||
#include "MeshManager.h" | #include "MeshManager.h" | ||||
#include "ObjectEntry.h" | #include "ObjectEntry.h" | ||||
#include "lib/res/graphics/ogl_tex.h" | #include "lib/res/graphics/ogl_tex.h" | ||||
#include "lib/res/h_mgr.h" | #include "lib/res/h_mgr.h" | ||||
#include "lib/sysdep/rtl.h" | #include "lib/sysdep/rtl.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/RenderingOptions.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/components/ICmpTerrain.h" | #include "simulation2/components/ICmpTerrain.h" | ||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// Constructor | // Constructor | ||||
CModel::CModel(CSkeletonAnimManager& skeletonAnimManager, CSimulation2& simulation) | CModel::CModel(CSkeletonAnimManager& skeletonAnimManager, CSimulation2& simulation) | ||||
: m_Flags(0), m_Anim(NULL), m_AnimTime(0), m_Simulation(simulation), | : m_Flags(0), m_Anim(NULL), m_AnimTime(0), m_Simulation(simulation), | ||||
▲ Show 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++) | ||||
m_BoneMatrices[i].Translate(m_pModelDef->GetBones()[i].m_Translation); | m_BoneMatrices[i].Translate(m_pModelDef->GetBones()[i].m_Translation); | ||||
} | } | ||||
} | } | ||||
// For CPU skinning, we precompute as much as possible so that the only | // For CPU skinning, we precompute as much as possible so that the only | ||||
// per-vertex work is a single matrix*vec multiplication. | // per-vertex work is a single matrix*vec multiplication. | ||||
// For GPU skinning, we try to minimise CPU work by doing most computation | // For GPU skinning, we try to minimise CPU work by doing most computation | ||||
// in the vertex shader instead. | // in the vertex shader instead. | ||||
// Using g_Renderer.m_Options to detect CPU vs GPU is a bit hacky, | // Using g_RenderingOptions to detect CPU vs GPU is a bit hacky, | ||||
// and this doesn't allow the setting to change at runtime, but there isn't | // and this doesn't allow the setting to change at runtime, but there isn't | ||||
// an obvious cleaner way to determine what data needs to be computed, | // an obvious cleaner way to determine what data needs to be computed, | ||||
// and GPU skinning is a rarely-used experimental feature anyway. | // and GPU skinning is a rarely-used experimental feature anyway. | ||||
bool worldSpaceBoneMatrices = !g_Renderer.m_Options.m_GPUSkinning; | bool worldSpaceBoneMatrices = !g_RenderingOptions.GetGPUSkinning(); | ||||
bool computeBlendMatrices = !g_Renderer.m_Options.m_GPUSkinning; | bool computeBlendMatrices = !g_RenderingOptions.GetGPUSkinning(); | ||||
if (m_BoneMatrices && worldSpaceBoneMatrices) | if (m_BoneMatrices && worldSpaceBoneMatrices) | ||||
{ | { | ||||
// add world-space transformation to m_BoneMatrices | // add world-space transformation to m_BoneMatrices | ||||
const CMatrix3D transform = GetTransform(); | const CMatrix3D transform = GetTransform(); | ||||
for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++) | for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++) | ||||
m_BoneMatrices[i].Concatenate(transform); | m_BoneMatrices[i].Concatenate(transform); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 299 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
2019