mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Merge pull request #129 from OpenMW/master while resolving conflicts
# Conflicts: # apps/openmw/mwworld/actiontake.cpp
This commit is contained in:
commit
c77120df6d
6 changed files with 69 additions and 54 deletions
|
@ -543,6 +543,10 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
|
boost::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
|
||||||
action->execute (actor);
|
action->execute (actor);
|
||||||
|
if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr)
|
||||||
|
{
|
||||||
|
updatePtr(ptr, action->getTarget());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float InterpreterContext::getSecondsPassed() const
|
float InterpreterContext::getSecondsPassed() const
|
||||||
|
@ -657,6 +661,9 @@ namespace MWScript
|
||||||
void InterpreterContext::updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated)
|
void InterpreterContext::updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated)
|
||||||
{
|
{
|
||||||
if (!mReference.isEmpty() && base == mReference)
|
if (!mReference.isEmpty() && base == mReference)
|
||||||
|
{
|
||||||
mReference = updated;
|
mReference = updated;
|
||||||
|
mLocals = &mReference.getRefData().getLocals();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,11 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const
|
||||||
return mTarget;
|
return mTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MWWorld::Action::setTarget(const MWWorld::Ptr& target)
|
||||||
|
{
|
||||||
|
mTarget = target;
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mSoundOffset(0), mTarget (target)
|
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mSoundOffset(0), mTarget (target)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,12 @@ namespace MWWorld
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
const Ptr& getTarget() const;
|
void setTarget(const Ptr&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
const Ptr& getTarget() const;
|
||||||
|
|
||||||
Action (bool keepSound = false, const Ptr& target = Ptr());
|
Action (bool keepSound = false, const Ptr& target = Ptr());
|
||||||
///< \param keepSound Keep playing the sound even if the object the sound is played on is removed.
|
///< \param keepSound Keep playing the sound even if the object the sound is played on is removed.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
||||||
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
||||||
actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
||||||
|
|
||||||
// Added by tes3mp
|
// Added by tes3mp
|
||||||
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||||
|
@ -41,5 +41,6 @@ namespace MWWorld
|
||||||
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
mwmp::Main::get().getLocalPlayer()->sendInventory();
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||||
|
setTarget(newitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1503,8 +1503,6 @@ namespace MWWorld
|
||||||
float diff = duration * osg::DegreesToRadians(90.f);
|
float diff = duration * osg::DegreesToRadians(90.f);
|
||||||
float targetRot = std::min(std::max(minRot, oldRot + diff * (it->second == 1 ? 1 : -1)), maxRot);
|
float targetRot = std::min(std::max(minRot, oldRot + diff * (it->second == 1 ? 1 : -1)), maxRot);
|
||||||
rotateObject(it->first, objPos.rot[0], objPos.rot[1], targetRot);
|
rotateObject(it->first, objPos.rot[0], objPos.rot[1], targetRot);
|
||||||
// the rotation order we want to use
|
|
||||||
mWorldScene->updateObjectRotation(it->first, false);
|
|
||||||
|
|
||||||
bool reached = (targetRot == maxRot && it->second) || targetRot == minRot;
|
bool reached = (targetRot == maxRot && it->second) || targetRot == minRot;
|
||||||
|
|
||||||
|
@ -1528,6 +1526,9 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the rotation order we want to use
|
||||||
|
mWorldScene->updateObjectRotation(it->first, false);
|
||||||
|
|
||||||
if (reached)
|
if (reached)
|
||||||
{
|
{
|
||||||
// Mark as non-moving
|
// Mark as non-moving
|
||||||
|
|
|
@ -210,7 +210,7 @@ public:
|
||||||
|
|
||||||
osg::ref_ptr<osg::VertexBufferObject> mVertexBuffer;
|
osg::ref_ptr<osg::VertexBufferObject> mVertexBuffer;
|
||||||
// need to hold on to this too as the mVertexBuffer does not hold a ref to its own array
|
// need to hold on to this too as the mVertexBuffer does not hold a ref to its own array
|
||||||
osg::ref_ptr<osg::UByteArray> mArray;
|
osg::ref_ptr<osg::Array> mArray;
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
osg::ref_ptr<osg::StateSet> mStateSet;
|
osg::ref_ptr<osg::StateSet> mStateSet;
|
||||||
|
@ -244,21 +244,25 @@ private:
|
||||||
|
|
||||||
class OSGVertexBuffer : public MyGUI::IVertexBuffer
|
class OSGVertexBuffer : public MyGUI::IVertexBuffer
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::VertexBufferObject> mBuffer;
|
osg::ref_ptr<osg::VertexBufferObject> mBuffer[2];
|
||||||
osg::ref_ptr<osg::UByteArray> mVertexArray;
|
osg::ref_ptr<osg::UByteArray> mVertexArray[2];
|
||||||
|
|
||||||
size_t mNeedVertexCount;
|
size_t mNeedVertexCount;
|
||||||
|
|
||||||
bool mQueuedForDrawing;
|
unsigned int mCurrentBuffer;
|
||||||
|
bool mUsed; // has the mCurrentBuffer been submitted to the rendering thread
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
void create();
|
osg::UByteArray* create();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSGVertexBuffer();
|
OSGVertexBuffer();
|
||||||
virtual ~OSGVertexBuffer();
|
virtual ~OSGVertexBuffer() {}
|
||||||
|
|
||||||
void markAsQueuedForDrawing();
|
void markUsed();
|
||||||
|
|
||||||
|
osg::Array* getVertexArray();
|
||||||
|
osg::VertexBufferObject* getVertexBuffer();
|
||||||
|
|
||||||
virtual void setVertexCount(size_t count);
|
virtual void setVertexCount(size_t count);
|
||||||
virtual size_t getVertexCount();
|
virtual size_t getVertexCount();
|
||||||
|
@ -266,26 +270,18 @@ public:
|
||||||
virtual MyGUI::Vertex *lock();
|
virtual MyGUI::Vertex *lock();
|
||||||
virtual void unlock();
|
virtual void unlock();
|
||||||
|
|
||||||
/*internal:*/
|
|
||||||
|
|
||||||
osg::VertexBufferObject *getBuffer() const { return mBuffer.get(); }
|
|
||||||
osg::UByteArray *getArray() const { return mVertexArray.get(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OSGVertexBuffer::OSGVertexBuffer()
|
OSGVertexBuffer::OSGVertexBuffer()
|
||||||
: mNeedVertexCount(0)
|
: mNeedVertexCount(0)
|
||||||
, mQueuedForDrawing(false)
|
, mCurrentBuffer(0)
|
||||||
|
, mUsed(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
OSGVertexBuffer::~OSGVertexBuffer()
|
void OSGVertexBuffer::markUsed()
|
||||||
{
|
{
|
||||||
destroy();
|
mUsed = true;
|
||||||
}
|
|
||||||
|
|
||||||
void OSGVertexBuffer::markAsQueuedForDrawing()
|
|
||||||
{
|
|
||||||
mQueuedForDrawing = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGVertexBuffer::setVertexCount(size_t count)
|
void OSGVertexBuffer::setVertexCount(size_t count)
|
||||||
|
@ -303,48 +299,51 @@ size_t OSGVertexBuffer::getVertexCount()
|
||||||
|
|
||||||
MyGUI::Vertex *OSGVertexBuffer::lock()
|
MyGUI::Vertex *OSGVertexBuffer::lock()
|
||||||
{
|
{
|
||||||
if (mQueuedForDrawing || !mVertexArray)
|
if (mUsed)
|
||||||
{
|
{
|
||||||
// Force recreating the buffer, to make sure we are not modifying a buffer currently
|
mCurrentBuffer = (mCurrentBuffer+1)%2;
|
||||||
// queued for rendering in the last frame's draw thread.
|
mUsed = false;
|
||||||
// a more efficient solution might be double buffering
|
|
||||||
destroy();
|
|
||||||
create();
|
|
||||||
mQueuedForDrawing = false;
|
|
||||||
}
|
}
|
||||||
else
|
osg::UByteArray* array = mVertexArray[mCurrentBuffer];
|
||||||
|
if (!array)
|
||||||
{
|
{
|
||||||
mVertexArray->resize(mNeedVertexCount * sizeof(MyGUI::Vertex));
|
array = create();
|
||||||
|
}
|
||||||
|
else if (array->size() != mNeedVertexCount * sizeof(MyGUI::Vertex))
|
||||||
|
{
|
||||||
|
array->resize(mNeedVertexCount * sizeof(MyGUI::Vertex));
|
||||||
}
|
}
|
||||||
|
|
||||||
MYGUI_PLATFORM_ASSERT(mBuffer.valid(), "Vertex buffer is not created");
|
return (MyGUI::Vertex*)&(*array)[0];
|
||||||
|
|
||||||
return (MyGUI::Vertex*)&(*mVertexArray)[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGVertexBuffer::unlock()
|
void OSGVertexBuffer::unlock()
|
||||||
{
|
{
|
||||||
mVertexArray->dirty();
|
mVertexArray[mCurrentBuffer]->dirty();
|
||||||
mBuffer->dirty();
|
mBuffer[mCurrentBuffer]->dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGVertexBuffer::destroy()
|
osg::UByteArray* OSGVertexBuffer::create()
|
||||||
{
|
{
|
||||||
mBuffer = nullptr;
|
mVertexArray[mCurrentBuffer] = new osg::UByteArray(mNeedVertexCount*sizeof(MyGUI::Vertex));
|
||||||
mVertexArray = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OSGVertexBuffer::create()
|
mBuffer[mCurrentBuffer] = new osg::VertexBufferObject;
|
||||||
{
|
mBuffer[mCurrentBuffer]->setDataVariance(osg::Object::DYNAMIC);
|
||||||
MYGUI_PLATFORM_ASSERT(!mBuffer.valid(), "Vertex buffer already exist");
|
mBuffer[mCurrentBuffer]->setUsage(GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
mVertexArray = new osg::UByteArray(mNeedVertexCount*sizeof(MyGUI::Vertex));
|
|
||||||
|
|
||||||
mBuffer = new osg::VertexBufferObject;
|
|
||||||
mBuffer->setDataVariance(osg::Object::DYNAMIC);
|
|
||||||
mBuffer->setUsage(GL_DYNAMIC_DRAW);
|
|
||||||
// NB mBuffer does not own the array
|
// NB mBuffer does not own the array
|
||||||
mBuffer->setArray(0, mVertexArray.get());
|
mBuffer[mCurrentBuffer]->setArray(0, mVertexArray[mCurrentBuffer].get());
|
||||||
|
|
||||||
|
return mVertexArray[mCurrentBuffer];
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Array* OSGVertexBuffer::getVertexArray()
|
||||||
|
{
|
||||||
|
return mVertexArray[mCurrentBuffer];
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::VertexBufferObject* OSGVertexBuffer::getVertexBuffer()
|
||||||
|
{
|
||||||
|
return mBuffer[mCurrentBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -438,9 +437,9 @@ void RenderManager::doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *text
|
||||||
{
|
{
|
||||||
Drawable::Batch batch;
|
Drawable::Batch batch;
|
||||||
batch.mVertexCount = count;
|
batch.mVertexCount = count;
|
||||||
batch.mVertexBuffer = static_cast<OSGVertexBuffer*>(buffer)->getBuffer();
|
batch.mVertexBuffer = static_cast<OSGVertexBuffer*>(buffer)->getVertexBuffer();
|
||||||
static_cast<OSGVertexBuffer*>(buffer)->markAsQueuedForDrawing();
|
batch.mArray = static_cast<OSGVertexBuffer*>(buffer)->getVertexArray();
|
||||||
batch.mArray = static_cast<OSGVertexBuffer*>(buffer)->getArray();
|
static_cast<OSGVertexBuffer*>(buffer)->markUsed();
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
batch.mTexture = static_cast<OSGTexture*>(texture)->getTexture();
|
batch.mTexture = static_cast<OSGTexture*>(texture)->getTexture();
|
||||||
|
|
Loading…
Reference in a new issue