[colobot] 55/145: Do not store exact object part positions
Didier Raboud
odyx at moszumanska.debian.org
Mon Jul 11 12:56:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit ae4e875729e6d2fddbf3a75349427d3c08a33dbf
Author: krzys-h <krzys_h at interia.pl>
Date: Fri Apr 8 18:28:35 2016 +0200
Do not store exact object part positions
This seems to be unnecessary, as the animation update code should set those on its own. Needs some more testing though.
---
src/level/robotmain.cpp | 55 ++----------------------------------------
src/object/task/taskshield.cpp | 13 +++++++++-
2 files changed, 14 insertions(+), 54 deletions(-)
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
index 274118b..4fa11f3 100644
--- a/src/level/robotmain.cpp
+++ b/src/level/robotmain.cpp
@@ -4529,33 +4529,6 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std::
if (obj->Implements(ObjectInterfaceType::Old))
{
- COldObject* oldObj = dynamic_cast<COldObject*>(obj);
-
- for (int i = 1; i < OBJECTMAXPART; i++)
- {
- if (oldObj->GetObjectRank(i) == -1) continue;
-
- Math::Vector pos = oldObj->GetPartPosition(i);
- if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
- {
- pos /= g_unit;
- line->AddParam("p" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(pos));
- }
-
- Math::Vector rot = oldObj->GetPartRotation(i);
- if (rot.x != 0.0f || rot.y != 0.0f || rot.z != 0.0f)
- {
- rot /= (Math::PI/180.0f);
- line->AddParam("a" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(rot));
- }
-
- Math::Vector scale = oldObj->GetPartScale(i);
- if (scale.x != 1.0f || scale.y != 1.0f || scale.z != 1.0f)
- {
- line->AddParam("z" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(scale));
- }
- }
-
line->AddParam("option", MakeUnique<CLevelParserParam>(obj->GetOption()));
}
@@ -4576,7 +4549,7 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std::
if (obj->Implements(ObjectInterfaceType::ProgramStorage))
{
CProgramStorageObject* programStorage = dynamic_cast<CProgramStorageObject*>(obj);
- if(programStorage->GetProgramStorageIndex() >= 0)
+ if (programStorage->GetProgramStorageIndex() >= 0)
{
programStorage->SaveAllProgramsForSavedScene(line, programDir);
}
@@ -4772,32 +4745,8 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const std::string& pro
if (obj->Implements(ObjectInterfaceType::Old))
{
COldObject* oldObj = dynamic_cast<COldObject*>(obj);
-
oldObj->SetPosition(line->GetParam("pos")->AsPoint() * g_unit);
oldObj->SetRotation(line->GetParam("angle")->AsPoint() * Math::DEG_TO_RAD);
-
- for (int i = 1; i < OBJECTMAXPART; i++)
- {
- if (oldObj->GetObjectRank(i) == -1) continue;
-
- Math::Vector pos = line->GetParam(std::string("p")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
- if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
- {
- oldObj->SetPartPosition(i, pos*g_unit);
- }
-
- Math::Vector dir = line->GetParam(std::string("a")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
- if (dir.x != 0.0f || dir.y != 0.0f || dir.z != 0.0f)
- {
- oldObj->SetPartRotation(i, dir*(Math::PI/180.0f));
- }
-
- Math::Vector zoom = line->GetParam(std::string("z")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
- if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
- {
- oldObj->SetPartScale(i, zoom);
- }
- }
}
if (obj->GetType() == OBJECT_BASE) m_base = obj;
@@ -4815,7 +4764,7 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const std::string& pro
if (obj->Implements(ObjectInterfaceType::ProgramStorage))
{
CProgramStorageObject* programStorage = dynamic_cast<CProgramStorageObject*>(obj);
- if (!line->GetParam("programStorageIndex")->IsDefined()) // Backwards combatibility
+ if (!line->GetParam("programStorageIndex")->IsDefined()) // Backwards compatibility
programStorage->SetProgramStorageIndex(objRank);
programStorage->LoadAllProgramsForSavedScene(line, programDir);
}
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index 7f2baa0..09e1da4 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -258,10 +258,21 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
if ( mode == TSM_START )
{
+ Math::Vector pos;
Math::Point dim;
+ pos.x = 7.0f;
+ pos.y = 4.5f+3.0f;
+ pos.z = 0.0f;
+ m_object->SetPartPosition(2, pos);
+
+ pos.x = 0.0f;
+ pos.y = 1.0f+3.0f;
+ pos.z = 0.0f;
+ m_object->SetPartPosition(3, pos);
+
Math::Matrix* mat = m_object->GetWorldMatrix(0);
- Math::Vector pos = Math::Vector(7.0f, 15.0f, 0.0f);
+ pos = Math::Vector(7.0f, 15.0f, 0.0f);
pos = Transform(*mat, pos); // sphere position
m_shieldPos = pos;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list