Skip to content

Commit 116005f

Browse files
authored
Merge branch 'OGRECave:master' into RenderingThread
2 parents a02e2f1 + 23fa502 commit 116005f

34 files changed

+1387
-1636
lines changed

OgreMain/include/OgreAutoParamDataSource.h

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ namespace Ogre {
105105
mutable bool mShadowCamDepthRangesDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
106106
ColourValue mAmbientLight;
107107
ColourValue mFogColour;
108+
ColourValue mShadowColour;
108109
Vector4f mFogParams;
109110
Vector4f mPointParams;
110111
int mPassNumber;
@@ -163,8 +164,10 @@ namespace Ogre {
163164
size_t getBoneMatrixCount(void) const;
164165
OGRE_DEPRECATED size_t getWorldMatrixCount(void) const { return getBoneMatrixCount(); }
165166
const Affine3& getViewMatrix(void) const;
167+
Affine3 getViewMatrix(const Camera* cam) const;
166168
const Matrix4& getViewProjectionMatrix(void) const;
167169
const Matrix4& getProjectionMatrix(void) const;
170+
Matrix4 getProjectionMatrix(const Camera* cam) const;
168171
const Matrix4& getWorldViewProjMatrix(void) const;
169172
const Affine3& getWorldViewMatrix(void) const;
170173
const Affine3& getInverseWorldMatrix(void) const;
@@ -221,6 +224,7 @@ namespace Ogre {
221224
Real getShadowExtrusionDistance(void) const;
222225
const Vector4& getSceneDepthRange() const;
223226
const Vector4& getShadowSceneDepthRange(size_t index) const;
227+
void setShadowColour(const ColourValue& colour);
224228
const ColourValue& getShadowColour() const;
225229
Matrix4 getInverseViewProjMatrix(void) const;
226230
Matrix4 getInverseTransposeViewProjMatrix() const;

OgreMain/include/OgreManualObject.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ namespace Ogre
556556
{
557557
protected:
558558
ManualObject* mParent;
559-
String mMaterialName;
560-
String mGroupName;
561559
mutable MaterialPtr mMaterial;
562560
RenderOperation mRenderOperation;
563561
bool m32BitIndices;
@@ -575,9 +573,9 @@ namespace Ogre
575573
/// Retrieve render operation for manipulation
576574
RenderOperation* getRenderOperation(void);
577575
/// Retrieve the material name in use
578-
const String& getMaterialName(void) const { return mMaterialName; }
576+
const String& getMaterialName(void) const { return mMaterial ? mMaterial->getName() : BLANKSTRING; }
579577
/// Retrieve the material group in use
580-
const String& getMaterialGroup(void) const { return mGroupName; }
578+
const String& getMaterialGroup(void) const { return mMaterial ? mMaterial->getGroup() : BLANKSTRING; }
581579
/// update the material name in use
582580
void setMaterialName(const String& name,
583581
const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);

OgreMain/include/OgreSceneManager.h

+168-150
Large diffs are not rendered by default.

OgreMain/include/OgreTexture.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ namespace Ogre {
400400
@remarks The buffer is invalidated when the resource is unloaded or destroyed.
401401
Do not use it after the lifetime of the containing texture.
402402
*/
403-
virtual const HardwarePixelBufferSharedPtr& getBuffer(size_t face=0, size_t mipmap=0) const;
403+
virtual const HardwarePixelBufferSharedPtr& getBuffer(size_t face=0, size_t mipmap=0);
404404

405405

406406
/** Populate an Image with the contents of this texture.
@@ -495,6 +495,15 @@ namespace Ogre {
495495
*/
496496
virtual void freeInternalResourcesImpl(void) = 0;
497497

498+
virtual HardwarePixelBufferPtr createSurface(uint32 face, uint32 mip, uint32 width, uint32 height, uint32 depth)
499+
{
500+
return nullptr;
501+
}
502+
503+
/// internal method, create HardwarePixelBuffers for every face and
504+
/// mipmap level. This method must be called after the texture object was created
505+
void createSurfaceList(void);
506+
498507
/** Default implementation of unload which calls freeInternalResources */
499508
void unloadImpl(void) override;
500509

OgreMain/include/OgreTextureManager.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,8 @@ namespace Ogre {
435435
: Texture(creator, name, handle, group)
436436
{
437437
}
438-
const HardwarePixelBufferSharedPtr& getBuffer(size_t, size_t) const override
439-
{
440-
static HardwarePixelBufferSharedPtr nullBuffer;
441-
return nullBuffer;
442-
}
443-
444438
protected:
445-
void createInternalResourcesImpl() override {}
439+
void createInternalResourcesImpl() override { createSurfaceList(); }
446440
void freeInternalResourcesImpl() override {}
447441
void loadImpl() override {}
448442
};

OgreMain/src/OgreAutoParamDataSource.cpp

+52-33
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Ogre {
5151
mCameraPositionDirty(true),
5252
mCameraPositionObjectSpaceDirty(true),
5353
mAmbientLight(ColourValue::Black),
54+
mShadowColour(ColourValue(0.25, 0.25, 0.25)),
5455
mPassNumber(0),
5556
mSceneDepthRangeDirty(true),
5657
mLodCameraPositionDirty(true),
@@ -306,21 +307,26 @@ namespace Ogre {
306307
return mWorldMatrixArray + int(MeshManager::getBonesUseObjectSpace());
307308
}
308309
//-----------------------------------------------------------------------------
309-
const Affine3& AutoParamDataSource::getViewMatrix(void) const
310+
Affine3 AutoParamDataSource::getViewMatrix(const Camera* cam) const
310311
{
311-
if (mViewMatrixDirty)
312+
Affine3 view;
313+
if (mCurrentRenderable && mCurrentRenderable->getUseIdentityView())
314+
view = Affine3::IDENTITY;
315+
else
312316
{
313-
if (mCurrentRenderable && mCurrentRenderable->getUseIdentityView())
314-
mViewMatrix = Affine3::IDENTITY;
315-
else
317+
view = cam->getViewMatrix(true);
318+
if (mCameraRelativeRendering)
316319
{
317-
mViewMatrix = mCurrentCamera->getViewMatrix(true);
318-
if (mCameraRelativeRendering)
319-
{
320-
mViewMatrix.setTrans(Vector3::ZERO);
321-
}
322-
320+
view.setTrans(Vector3::ZERO);
323321
}
322+
}
323+
return view;
324+
}
325+
const Affine3& AutoParamDataSource::getViewMatrix(void) const
326+
{
327+
if (mViewMatrixDirty)
328+
{
329+
mViewMatrix = getViewMatrix(mCurrentCamera);
324330
mViewMatrixDirty = false;
325331
}
326332
return mViewMatrix;
@@ -336,31 +342,40 @@ namespace Ogre {
336342
return mViewProjMatrix;
337343
}
338344
//-----------------------------------------------------------------------------
345+
Matrix4 AutoParamDataSource::getProjectionMatrix(const Camera* cam) const
346+
{
347+
Matrix4 proj;
348+
349+
// NB use API-independent projection matrix since GPU programs
350+
// bypass the API-specific handedness and use right-handed coords
351+
if (mCurrentRenderable && mCurrentRenderable->getUseIdentityProjection())
352+
{
353+
// Use identity projection matrix, still need to take RS depth into account.
354+
RenderSystem* rs = Root::getSingleton().getRenderSystem();
355+
rs->_convertProjectionMatrix(Matrix4::IDENTITY, proj, true);
356+
}
357+
else
358+
{
359+
proj = mCurrentCamera->getProjectionMatrixWithRSDepth();
360+
}
361+
362+
if (mCurrentRenderTarget && mCurrentRenderTarget->requiresTextureFlipping())
363+
{
364+
// Because we're not using setProjectionMatrix, this needs to be done here
365+
// Invert transformed y
366+
proj[1][0] = -proj[1][0];
367+
proj[1][1] = -proj[1][1];
368+
proj[1][2] = -proj[1][2];
369+
proj[1][3] = -proj[1][3];
370+
}
371+
372+
return proj;
373+
}
339374
const Matrix4& AutoParamDataSource::getProjectionMatrix(void) const
340375
{
341376
if (mProjMatrixDirty)
342377
{
343-
// NB use API-independent projection matrix since GPU programs
344-
// bypass the API-specific handedness and use right-handed coords
345-
if (mCurrentRenderable && mCurrentRenderable->getUseIdentityProjection())
346-
{
347-
// Use identity projection matrix, still need to take RS depth into account.
348-
RenderSystem* rs = Root::getSingleton().getRenderSystem();
349-
rs->_convertProjectionMatrix(Matrix4::IDENTITY, mProjectionMatrix, true);
350-
}
351-
else
352-
{
353-
mProjectionMatrix = mCurrentCamera->getProjectionMatrixWithRSDepth();
354-
}
355-
if (mCurrentRenderTarget && mCurrentRenderTarget->requiresTextureFlipping())
356-
{
357-
// Because we're not using setProjectionMatrix, this needs to be done here
358-
// Invert transformed y
359-
mProjectionMatrix[1][0] = -mProjectionMatrix[1][0];
360-
mProjectionMatrix[1][1] = -mProjectionMatrix[1][1];
361-
mProjectionMatrix[1][2] = -mProjectionMatrix[1][2];
362-
mProjectionMatrix[1][3] = -mProjectionMatrix[1][3];
363-
}
378+
mProjectionMatrix = getProjectionMatrix(mCurrentCamera);
364379
mProjMatrixDirty = false;
365380
}
366381
return mProjectionMatrix;
@@ -1132,9 +1147,13 @@ namespace Ogre {
11321147
return dummy;
11331148
}
11341149
//---------------------------------------------------------------------
1150+
void AutoParamDataSource::setShadowColour(const ColourValue& colour)
1151+
{
1152+
mShadowColour = colour;
1153+
}
11351154
const ColourValue& AutoParamDataSource::getShadowColour() const
11361155
{
1137-
return mCurrentSceneManager->getShadowColour();
1156+
return mShadowColour;
11381157
}
11391158
//-------------------------------------------------------------------------
11401159
void AutoParamDataSource::updateLightCustomGpuParameter(const GpuProgramParameters::AutoConstantEntry& constantEntry, GpuProgramParameters *params) const

OgreMain/src/OgreBillboardSet.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ namespace Ogre {
489489
{
490490
op.operationType = RenderOperation::OT_POINT_LIST;
491491
op.useIndexes = false;
492-
op.useGlobalInstancing = false;
493492
op.indexData = 0;
494493
op.vertexData->vertexCount = mNumVisibleBillboards;
495494
}

OgreMain/src/OgreManualObject.cpp

+8-25
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ ManualObject::ManualObject(const String& name)
257257
rop->vertexData->vertexDeclaration->getElements();
258258
for (const auto & elem : elemList)
259259
{
260+
if(elem.getSource() != 0)
261+
continue; // not our buffer (e.g. auto instancing injection)
262+
260263
float* pFloat = 0;
261264
RGBA* pRGBA = 0;
262265
switch(elem.getType())
@@ -628,28 +631,19 @@ ManualObject::ManualObject(const String& name)
628631
//-----------------------------------------------------------------------------
629632
//-----------------------------------------------------------------------------
630633
//-----------------------------------------------------------------------------
631-
ManualObject::ManualObjectSection::ManualObjectSection(ManualObject* parent,
632-
const String& materialName, RenderOperation::OperationType opType, const String & groupName)
633-
: mParent(parent), mMaterialName(materialName), mGroupName(groupName), m32BitIndices(false)
634+
ManualObject::ManualObjectSection::ManualObjectSection(ManualObject* parent, const String& materialName,
635+
RenderOperation::OperationType opType,
636+
const String& groupName)
637+
: ManualObjectSection(parent, MaterialManager::getSingleton().getByName(materialName, groupName), opType)
634638
{
635-
mRenderOperation.operationType = opType;
636-
// default to no indexes unless we're told
637-
mRenderOperation.useIndexes = false;
638-
mRenderOperation.useGlobalInstancing = false;
639-
mRenderOperation.vertexData = OGRE_NEW VertexData();
640-
mRenderOperation.vertexData->vertexCount = 0;
641639
}
642640
ManualObject::ManualObjectSection::ManualObjectSection(ManualObject* parent,
643641
const MaterialPtr& mat, RenderOperation::OperationType opType)
644642
: mParent(parent), mMaterial(mat), m32BitIndices(false)
645643
{
646644
assert(mMaterial);
647-
mMaterialName = mMaterial->getName();
648-
mGroupName = mMaterial->getGroup();
649-
650645
mRenderOperation.operationType = opType;
651646
mRenderOperation.useIndexes = false;
652-
mRenderOperation.useGlobalInstancing = false;
653647
mRenderOperation.vertexData = OGRE_NEW VertexData();
654648
mRenderOperation.vertexData->vertexCount = 0;
655649
}
@@ -667,30 +661,19 @@ ManualObject::ManualObject(const String& name)
667661
//-----------------------------------------------------------------------------
668662
const MaterialPtr& ManualObject::ManualObjectSection::getMaterial(void) const
669663
{
670-
if (!mMaterial)
671-
{
672-
mMaterial = static_pointer_cast<Material>(MaterialManager::getSingleton().load(mMaterialName, mGroupName));
673-
}
674664
return mMaterial;
675665
}
676666
//-----------------------------------------------------------------------------
677667
void ManualObject::ManualObjectSection::setMaterialName(const String& name,
678668
const String& groupName /* = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME */)
679669
{
680-
if (mMaterialName != name || mGroupName != groupName)
681-
{
682-
mMaterialName = name;
683-
mGroupName = groupName;
684-
mMaterial.reset();
685-
}
670+
mMaterial = MaterialManager::getSingleton().getByName(name, groupName);
686671
}
687672
//-----------------------------------------------------------------------------
688673
void ManualObject::ManualObjectSection::setMaterial(const MaterialPtr& mat)
689674
{
690675
assert(mat);
691676
mMaterial = mat;
692-
mMaterialName = mat->getName();
693-
mGroupName = mat->getGroup();
694677
}
695678
//-----------------------------------------------------------------------------
696679
void ManualObject::ManualObjectSection::getRenderOperation(RenderOperation& op)

OgreMain/src/OgreRectangle2D.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ namespace Ogre {
5858
mRenderOp.vertexData->vertexCount = 4;
5959
mRenderOp.vertexData->vertexStart = 0;
6060
mRenderOp.operationType = RenderOperation::OT_TRIANGLE_STRIP;
61-
mRenderOp.useIndexes = false;
62-
mRenderOp.useGlobalInstancing = false;
61+
mRenderOp.useIndexes = false;
6362

6463
VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
6564
VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;

0 commit comments

Comments
 (0)