Snake/src/Core/Crawl/groupobject.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

2021-07-29 21:51:31 +03:00
//#
//# Copyright (C) 2021-2021 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "clasteritem.h"
#include "groupobject.h"
namespace CRAWL {
GroupObject::GroupObject() {
}
void GroupObject::render(unsigned int tbfMsec) {
Q_UNUSED(tbfMsec)
GuiObject* _this = checkminimumRequariedType<GuiObject>();
for (ClasterItem* object: objects()) {
2021-08-03 21:01:16 +03:00
if (Localpropertys *props = getLocalpropertys(object->guiId())) {
2021-07-29 21:51:31 +03:00
if (!props->_rotation.isNull())
2021-07-30 13:19:19 +03:00
object->setRotation(_this->rotation() * props->_rotation);
2021-07-29 21:51:31 +03:00
object->setposition(_this->position() + props->_position);
}
}
}
void GroupObject::installObject(ClasterItem *object,
const QVector3D &localPosition,
const QQuaternion &localRotation) {
updatePosition(object->guiId(), localPosition);
updateRotation(object->guiId(), localRotation);
Claster::add(object);
}
void GroupObject::updatePosition(int id, const QVector3D &position) {
2021-08-03 21:01:16 +03:00
_extrapropertys[id]._position = position;
2021-07-29 21:51:31 +03:00
}
void GroupObject::updateRotation(int id, const QQuaternion &roatation) {
2021-08-03 21:01:16 +03:00
_extrapropertys[id]._rotation = roatation;
2021-07-29 21:51:31 +03:00
}
QQuaternion *GroupObject::getLocalrotation(int id) {
2021-08-03 21:01:16 +03:00
if (_extrapropertys.contains(id)) {
return &_extrapropertys[id]._rotation;
2021-07-29 21:51:31 +03:00
}
return nullptr;
}
QVector3D *GroupObject::getLocalPosition(int id) {
2021-08-03 21:01:16 +03:00
if (_extrapropertys.contains(id)) {
return &_extrapropertys[id]._position;
2021-07-29 21:51:31 +03:00
}
return nullptr;
}
2021-08-03 21:01:16 +03:00
Localpropertys *GroupObject::getLocalpropertys(int id) {
if (_extrapropertys.contains(id)) {
return &_extrapropertys[id];
2021-07-29 21:51:31 +03:00
}
return nullptr;
}
}