Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.com:openmw/openmw into doc_has_more_p…
Browse files Browse the repository at this point in the history
…robls
  • Loading branch information
Zackhasacat committed May 7, 2024
2 parents 112dfca + b906983 commit 921ee8f
Show file tree
Hide file tree
Showing 51 changed files with 2,615 additions and 170 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 49)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 60)
set(OPENMW_LUA_API_REVISION 61)
set(OPENMW_POSTPROCESSING_API_REVISION 1)

set(OPENMW_VERSION_COMMITHASH "")
Expand Down
3 changes: 2 additions & 1 deletion apps/essimporter/importproj.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define OPENMW_ESSIMPORT_IMPORTPROJ_H

#include <components/esm/esmcommon.hpp>
#include <components/esm/util.hpp>
#include <components/esm/vector3.hpp>

#include <cstdint>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions apps/launcher/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<width>775</width>
<height>635</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>750</width>
<width>775</width>
<height>635</height>
</size>
</property>
Expand Down
4 changes: 3 additions & 1 deletion apps/opencs/view/world/scriptedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <vector>

#include <QApplication>
#include <QDragEnterEvent>
#include <QMenu>
#include <QPainter>
Expand Down Expand Up @@ -424,6 +425,7 @@ void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent* event)
painter.setBackgroundMode(Qt::OpaqueMode);
QFont font = painter.font();
QBrush background = painter.background();
QColor textColor = QApplication::palette().text().color();

while (block.isValid() && top <= event->rect().bottom())
{
Expand All @@ -440,7 +442,7 @@ void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent* event)
else
{
painter.setBackground(background);
painter.setPen(Qt::black);
painter.setPen(textColor);
}
painter.setFont(newFont);
painter.drawText(0, top, mLineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number);
Expand Down
7 changes: 6 additions & 1 deletion apps/openmw/mwgui/loadingscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ namespace MWGui

MWBase::Environment::get().getInputManager()->update(0, true, true);

mResourceSystem->reportStats(mViewer->getFrameStamp()->getFrameNumber(), mViewer->getViewerStats());
osg::Stats* const stats = mViewer->getViewerStats();
const unsigned frameNumber = mViewer->getFrameStamp()->getFrameNumber();

stats->setAttribute(frameNumber, "Loading", 1);

mResourceSystem->reportStats(frameNumber, stats);
if (osgUtil::IncrementalCompileOperation* ico = mViewer->getIncrementalCompileOperation())
{
ico->setMinimumTimeAvailableForGLCompileAndDeletePerFrame(1.f / getTargetFrameRate());
Expand Down
62 changes: 49 additions & 13 deletions apps/openmw/mwlua/localscripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,27 @@ namespace MWLua
});
aiPackage["sideWithTarget"] = sol::readonly_property([](const AiPackage& p) { return p.sideWithTarget(); });
aiPackage["destPosition"] = sol::readonly_property([](const AiPackage& p) { return p.getDestination(); });
aiPackage["distance"] = sol::readonly_property([](const AiPackage& p) { return p.getDistance(); });
aiPackage["duration"] = sol::readonly_property([](const AiPackage& p) { return p.getDuration(); });
aiPackage["idle"] = sol::readonly_property([context](const AiPackage& p) -> sol::optional<sol::table> {
if (p.getTypeId() == MWMechanics::AiPackageTypeId::Wander)
{
sol::table idles(context.mLua->sol(), sol::create);
const std::vector<unsigned char>& idle = static_cast<const MWMechanics::AiWander&>(p).getIdle();
if (!idle.empty())
{
for (size_t i = 0; i < idle.size(); ++i)
{
std::string_view groupName = MWMechanics::AiWander::getIdleGroupName(i);
idles[groupName] = idle[i];
}
return idles;
}
}
return sol::nullopt;
});

aiPackage["isRepeat"] = sol::readonly_property([](const AiPackage& p) { return p.getRepeat(); });
selfAPI["_getActiveAiPackage"] = [](SelfObject& self) -> sol::optional<std::shared_ptr<AiPackage>> {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
Expand Down Expand Up @@ -132,37 +152,53 @@ namespace MWLua
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
ai.stack(MWMechanics::AiPursue(target.ptr()), ptr, cancelOther);
};
selfAPI["_startAiFollow"] = [](SelfObject& self, const LObject& target, bool cancelOther) {
selfAPI["_startAiFollow"] = [](SelfObject& self, const LObject& target, sol::optional<LCell> cell,
float duration, const osg::Vec3f& dest, bool repeat, bool cancelOther) {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
ai.stack(MWMechanics::AiFollow(target.ptr()), ptr, cancelOther);
if (cell)
{
ai.stack(MWMechanics::AiFollow(target.ptr().getCellRef().getRefId(),
cell->mStore->getCell()->getNameId(), duration, dest.x(), dest.y(), dest.z(), repeat),
ptr, cancelOther);
}
else
{
ai.stack(MWMechanics::AiFollow(
target.ptr().getCellRef().getRefId(), duration, dest.x(), dest.y(), dest.z(), repeat),
ptr, cancelOther);
}
};
selfAPI["_startAiEscort"] = [](SelfObject& self, const LObject& target, LCell cell, float duration,
const osg::Vec3f& dest, bool cancelOther) {
const osg::Vec3f& dest, bool repeat, bool cancelOther) {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
// TODO: change AiEscort implementation to accept ptr instead of a non-unique refId.
const ESM::RefId& refId = target.ptr().getCellRef().getRefId();
int gameHoursDuration = static_cast<int>(std::ceil(duration / 3600.0));
auto* esmCell = cell.mStore->getCell();
if (esmCell->isExterior())
ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr,
ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), repeat), ptr,
cancelOther);
else
ai.stack(MWMechanics::AiEscort(
refId, esmCell->getNameId(), gameHoursDuration, dest.x(), dest.y(), dest.z(), false),
refId, esmCell->getNameId(), gameHoursDuration, dest.x(), dest.y(), dest.z(), repeat),
ptr, cancelOther);
};
selfAPI["_startAiWander"] = [](SelfObject& self, int distance, float duration, bool cancelOther) {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
int gameHoursDuration = static_cast<int>(std::ceil(duration / 3600.0));
ai.stack(MWMechanics::AiWander(distance, gameHoursDuration, 0, {}, false), ptr, cancelOther);
};
selfAPI["_startAiTravel"] = [](SelfObject& self, const osg::Vec3f& target, bool cancelOther) {
selfAPI["_startAiWander"]
= [](SelfObject& self, int distance, int duration, sol::table luaIdle, bool repeat, bool cancelOther) {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
std::vector<unsigned char> idle;
// Lua index starts at 1
for (size_t i = 1; i <= luaIdle.size(); i++)
idle.emplace_back(luaIdle.get<unsigned char>(i));
ai.stack(MWMechanics::AiWander(distance, duration, 0, idle, repeat), ptr, cancelOther);
};
selfAPI["_startAiTravel"] = [](SelfObject& self, const osg::Vec3f& target, bool repeat, bool cancelOther) {
const MWWorld::Ptr& ptr = self.ptr();
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
ai.stack(MWMechanics::AiTravel(target.x(), target.y(), target.z(), false), ptr, cancelOther);
ai.stack(MWMechanics::AiTravel(target.x(), target.y(), target.z(), repeat), ptr, cancelOther);
};
selfAPI["_enableLuaAnimations"] = [](SelfObject& self, bool enable) {
const MWWorld::Ptr& ptr = self.ptr();
Expand Down
1 change: 1 addition & 0 deletions apps/openmw/mwmechanics/aiescort.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "aiescort.hpp"

#include <components/esm/util.hpp>
#include <components/esm3/aisequence.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/misc/algorithm.hpp>
Expand Down
2 changes: 2 additions & 0 deletions apps/openmw/mwmechanics/aiescort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace MWMechanics

osg::Vec3f getDestination() const override { return osg::Vec3f(mX, mY, mZ); }

std::optional<float> getDuration() const override { return mDuration; }

private:
const std::string mCellId;
const float mX;
Expand Down
4 changes: 4 additions & 0 deletions apps/openmw/mwmechanics/aipackage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ namespace MWMechanics

virtual osg::Vec3f getDestination() const { return osg::Vec3f(0, 0, 0); }

virtual std::optional<int> getDistance() const { return std::nullopt; }

virtual std::optional<float> getDuration() const { return std::nullopt; }

/// Return true if any loaded actor with this AI package must be active.
bool alwaysActive() const { return mOptions.mAlwaysActive; }

Expand Down
8 changes: 8 additions & 0 deletions apps/openmw/mwmechanics/aiwander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ namespace MWMechanics

bool isStationary() const { return mDistance == 0; }

std::optional<int> getDistance() const override { return mDistance; }

std::optional<float> getDuration() const override { return static_cast<float>(mDuration); }

const std::vector<unsigned char>& getIdle() const { return mIdle; }

static std::string_view getIdleGroupName(size_t index) { return sIdleSelectToGroupName[index]; }

private:
void stopWalking(const MWWorld::Ptr& actor);

Expand Down
2 changes: 2 additions & 0 deletions apps/openmw/mwphysics/mtphysics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include <atomic>
#include <condition_variable>
#include <memory>
#include <optional>
#include <set>
#include <shared_mutex>
#include <thread>
#include <unordered_set>
Expand Down
3 changes: 0 additions & 3 deletions apps/openmw/mwphysics/physicssystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <unordered_map>
#include <variant>
Expand All @@ -16,8 +15,6 @@
#include <osg/Timer>
#include <osg/ref_ptr>

#include <components/esm/util.hpp>

#include "../mwworld/ptr.hpp"

#include "collisiontype.hpp"
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwrender/landmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <osg/Object>

#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esmterrain/storage.hpp>
#include <components/resource/resourcemanager.hpp>

Expand Down
14 changes: 11 additions & 3 deletions apps/openmw/mwrender/objectpaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,19 @@ namespace MWRender
// TODO
}

if (activeGrid)
if (activeGrid && !refs.empty())
{
std::lock_guard<std::mutex> lock(mRefTrackerMutex);
for (auto ref : getRefTracker().mBlacklist)
refs.erase(ref);
const std::set<ESM::RefNum>& blacklist = getRefTracker().mBlacklist;
if (blacklist.size() < refs.size())
{
for (ESM::RefNum ref : blacklist)
refs.erase(ref);
}
else
{
std::erase_if(refs, [&](const auto& ref) { return blacklist.contains(ref.first); });
}
}

osg::Vec2f minBound = (center - osg::Vec2f(size / 2.f, size / 2.f));
Expand Down
4 changes: 3 additions & 1 deletion apps/openmw/mwscript/cellextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <components/misc/strings/algorithm.hpp>

#include <components/esm/util.hpp>

#include "../mwbase/environment.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwbase/windowmanager.hpp"
Expand Down Expand Up @@ -123,7 +125,7 @@ namespace MWScript
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr playerPtr = world->getPlayerPtr();

osg::Vec2 posFromIndex
const osg::Vec2f posFromIndex
= ESM::indexToPosition(ESM::ExteriorCellLocation(x, y, ESM::Cell::sDefaultWorldspaceId), true);
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();
Expand Down
2 changes: 2 additions & 0 deletions apps/openmw/mwscript/transformationextensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <components/esm3/loadcell.hpp>

#include <components/esm/util.hpp>

#include <components/compiler/opcodes.hpp>

#include <components/interpreter/interpreter.hpp>
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwstate/statemanagerimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
Log(Debug::Warning) << "Player character's cell no longer exists, changing to the default cell";
ESM::ExteriorCellLocation cellIndex(0, 0, ESM::Cell::sDefaultWorldspaceId);
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex);
osg::Vec2 posFromIndex = ESM::indexToPosition(cellIndex, false);
const osg::Vec2f posFromIndex = ESM::indexToPosition(cellIndex, false);
ESM::Position pos;
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwworld/cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <osg/Vec2i>

#include <components/esm/esmbridge.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/esm/refid.hpp>
#include <components/esm/util.hpp>

namespace ESM
{
Expand Down
3 changes: 3 additions & 0 deletions apps/openmw/mwworld/projectilemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <components/esm3/loadrace.hpp>
#include <components/esm3/projectilestate.hpp>

#include <components/esm/quaternion.hpp>
#include <components/esm/vector3.hpp>

#include <components/misc/constants.hpp>
#include <components/misc/convert.hpp>
#include <components/misc/resourcehelpers.hpp>
Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwworld/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ namespace MWWorld
= mCurrentCell ? mCurrentCell->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId;
if (currentGridCenter)
{
osg::Vec2 center = ESM::indexToPosition(
const osg::Vec2f center = ESM::indexToPosition(
ESM::ExteriorCellLocation(currentGridCenter->x(), currentGridCenter->y(), worldspace), true);
float distance = std::max(std::abs(center.x() - pos.x()), std::abs(center.y() - pos.y()));
float cellSize = ESM::getCellSize(worldspace);
Expand Down Expand Up @@ -1171,7 +1171,7 @@ namespace MWWorld
&& dx != -halfGridSizePlusOne)
continue; // only care about the outer (not yet loaded) part of the grid
ESM::ExteriorCellLocation cellIndex(cellX + dx, cellY + dy, extWorldspace);
osg::Vec2 thisCellCenter = ESM::indexToPosition(cellIndex, true);
const osg::Vec2f thisCellCenter = ESM::indexToPosition(cellIndex, true);

float dist = std::max(
std::abs(thisCellCenter.x() - playerPos.x()), std::abs(thisCellCenter.y() - playerPos.y()));
Expand Down
3 changes: 1 addition & 2 deletions apps/openmw/mwworld/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
#include <memory>
#include <optional>
#include <set>
#include <unordered_map>
#include <vector>

#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/misc/constants.hpp>

namespace osg
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwworld/worldimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,7 @@ namespace MWWorld

int x = ext->getGridX();
int y = ext->getGridY();
osg::Vec2 posFromIndex = indexToPosition(ESM::ExteriorCellLocation(x, y, ext->getWorldSpace()), true);
const osg::Vec2f posFromIndex = indexToPosition(ESM::ExteriorCellLocation(x, y, ext->getWorldSpace()), true);
pos.pos[0] = posFromIndex.x();
pos.pos[1] = posFromIndex.y();

Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwworld/worldmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_view>
#include <unordered_map>

#include <components/esm/util.hpp>
#include <components/esm/exteriorcelllocation.hpp>
#include <components/misc/algorithm.hpp>

#include "cellstore.hpp"
Expand Down
4 changes: 4 additions & 0 deletions components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ add_component_dir(esm attr common defs esmcommon records util luascripts format
indexrefid
serializerefid
esm3exteriorcellrefid
quaternion
vector3
exteriorcelllocation
)

add_component_dir(fx pass technique lexer lexer_types parse_constants widgets stateupdater)
Expand All @@ -186,6 +189,7 @@ add_component_dir (esm3
weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate debugprofile
aisequence magiceffects custommarkerstate stolenitems transport animationstate controlsstate mappings readerscache
infoorder timestamp formatversion landrecorddata selectiongroup dialoguecondition
refnum
)

add_component_dir (esmterrain
Expand Down
Loading

0 comments on commit 921ee8f

Please sign in to comment.