Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/ObjectEntry.cpp
/* Copyright (C) 2020 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* 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 24 Lines | |||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include <sstream> | #include <sstream> | ||||
CObjectEntry::CObjectEntry(CObjectBase* base, CSimulation2& simulation) : | CObjectEntry::CObjectEntry(const std::shared_ptr<CObjectBase>& base, CSimulation2& simulation) : | ||||
m_Base(base), m_Color(1.0f, 1.0f, 1.0f, 1.0f), m_Model(NULL), m_Outdated(false), m_Simulation(simulation) | m_Base(base), m_Color(1.0f, 1.0f, 1.0f, 1.0f), m_Model(NULL), m_Outdated(false), m_Simulation(simulation) | ||||
{ | { | ||||
} | } | ||||
CObjectEntry::~CObjectEntry() | CObjectEntry::~CObjectEntry() | ||||
{ | { | ||||
for (const std::pair<const CStr, CSkeletonAnim*>& anim : m_Animations) | for (const std::pair<const CStr, CSkeletonAnim*>& anim : m_Animations) | ||||
delete anim.second; | delete anim.second; | ||||
delete m_Model; | delete m_Model; | ||||
} | } | ||||
bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections, | bool CObjectEntry::BuildVariation(const std::vector<const std::set<CStr>*>& completeSelections, | ||||
const std::vector<u8>& variationKey, | const std::vector<u8>& variationKey, | ||||
CObjectManager& objectManager) | CObjectManager& objectManager) | ||||
{ | { | ||||
CObjectBase::Variation variation = m_Base->BuildVariation(variationKey); | CObjectBase::Variation variation = m_Base->BuildVariation(variationKey); | ||||
// Copy the chosen data onto this model: | // Copy the chosen data onto this model: | ||||
for (std::multimap<CStr, CObjectBase::Samp>::iterator it = variation.samplers.begin(); it != variation.samplers.end(); ++it) | for (std::multimap<CStr, CObjectBase::Samp>::iterator it = variation.samplers.begin(); it != variation.samplers.end(); ++it) | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | bool CObjectEntry::BuildVariation(const std::vector<const std::set<CStr>*>& completeSelections, | ||||
{ | { | ||||
// Pluck out the special attachpoint 'projectile' | // Pluck out the special attachpoint 'projectile' | ||||
if (prop.m_PropPointName == "projectile") | if (prop.m_PropPointName == "projectile") | ||||
{ | { | ||||
m_ProjectileModelName = prop.m_ModelName; | m_ProjectileModelName = prop.m_ModelName; | ||||
continue; | continue; | ||||
} | } | ||||
CObjectEntry* oe = objectManager.FindObjectVariation(prop.m_ModelName.c_str(), selections); | CObjectEntry* oe = nullptr; | ||||
if (CActorDef* actorDef = objectManager.FindActorDef(prop.m_ModelName.c_str()); actorDef) | |||||
oe = objectManager.FindObjectVariation(actorDef->GetBase(m_Base->m_QualityLevel), completeSelections); | |||||
if (!oe) | if (!oe) | ||||
{ | { | ||||
LOGERROR("Failed to build prop model \"%s\" on actor \"%s\"", utf8_from_wstring(prop.m_ModelName), utf8_from_wstring(m_Base->m_ShortName)); | LOGERROR("Failed to build prop model \"%s\" on actor \"%s\"", utf8_from_wstring(prop.m_ModelName), utf8_from_wstring(m_Base->m_ShortName)); | ||||
continue; | continue; | ||||
} | } | ||||
// If we don't have a projectile but this prop does (e.g. it's our rider), then | // If we don't have a projectile but this prop does (e.g. it's our rider), then | ||||
// use that as our projectile too | // use that as our projectile too | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator