-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
350 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
components/libRamsesBase/include/ramses_adaptor/TextureExternalAdaptor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* | ||
* This file is part of Ramses Composer | ||
* (see https://github.com/bmwcarit/ramses-composer). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
#pragma once | ||
|
||
#include "ramses_adaptor/ObjectAdaptor.h" | ||
#include "user_types/TextureExternal.h" | ||
|
||
#include <ramses-client-api/TextureSamplerExternal.h> | ||
|
||
#include <memory> | ||
|
||
namespace raco::ramses_adaptor { | ||
|
||
class TextureExternalAdaptor : public TypedObjectAdaptor<user_types::TextureExternal, ramses::TextureSamplerExternal> { | ||
public: | ||
explicit TextureExternalAdaptor(SceneAdaptor* sceneAdaptor, std::shared_ptr<user_types::TextureExternal> editorObject); | ||
|
||
bool sync(core::Errors* errors) override; | ||
std::vector<ExportInformation> getExportInformation() const override; | ||
|
||
private: | ||
std::array<components::Subscription, 2> subscriptions_; | ||
}; | ||
|
||
}; // namespace raco::ramses_adaptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
components/libRamsesBase/src/ramses_adaptor/TextureExternalAdaptor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* | ||
* This file is part of Ramses Composer | ||
* (see https://github.com/bmwcarit/ramses-composer). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
#include "ramses_adaptor/TextureExternalAdaptor.h" | ||
|
||
#include "ramses_adaptor/SceneAdaptor.h" | ||
#include "ramses_base/RamsesHandles.h" | ||
|
||
namespace raco::ramses_adaptor { | ||
|
||
using namespace raco::ramses_base; | ||
|
||
TextureExternalAdaptor::TextureExternalAdaptor(SceneAdaptor* sceneAdaptor, std::shared_ptr<user_types::TextureExternal> editorObject) | ||
: TypedObjectAdaptor(sceneAdaptor, editorObject, {}), | ||
subscriptions_{ | ||
sceneAdaptor->dispatcher()->registerOn(core::ValueHandle{editorObject, &user_types::TextureExternal::minSamplingMethod_}, [this]() { | ||
tagDirty(); | ||
}), | ||
sceneAdaptor->dispatcher()->registerOn(core::ValueHandle{editorObject, &user_types::TextureExternal::magSamplingMethod_}, [this]() { | ||
tagDirty(); | ||
})} { | ||
} | ||
|
||
bool TextureExternalAdaptor::sync(core::Errors* errors) { | ||
reset(ramsesTextureSamplerExternal(sceneAdaptor_->scene(), | ||
static_cast<ramses::ETextureSamplingMethod>(*editorObject()->minSamplingMethod_), | ||
static_cast<ramses::ETextureSamplingMethod>(*editorObject()->magSamplingMethod_))); | ||
|
||
tagDirty(false); | ||
return true; | ||
} | ||
|
||
std::vector<ExportInformation> TextureExternalAdaptor::getExportInformation() const { | ||
if (getRamsesObjectPointer()) { | ||
return { | ||
ExportInformation{ramsesObject().getType(), ramsesObject().getName()}, | ||
}; | ||
} | ||
return {}; | ||
} | ||
|
||
} // namespace raco::ramses_adaptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* | ||
* This file is part of Ramses Composer | ||
* (see https://github.com/bmwcarit/ramses-composer). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
#include <gtest/gtest.h> | ||
|
||
#include "RamsesBaseFixture.h" | ||
#include "ramses_adaptor/TextureExternalAdaptor.h" | ||
#include "testing/TestUtil.h" | ||
|
||
class TextureExternalAdaptorFixture : public RamsesBaseFixture<> {}; | ||
|
||
TEST_F(TextureExternalAdaptorFixture, creation_sets_name) { | ||
auto texture = create<raco::user_types::TextureExternal>("test"); | ||
|
||
dispatch(); | ||
|
||
auto engineSampler = select<ramses::TextureSamplerExternal>(*sceneContext.scene(), "test"); | ||
EXPECT_TRUE(engineSampler != nullptr); | ||
EXPECT_EQ(engineSampler->getName(), std::string("test")); | ||
} | ||
|
||
TEST_F(TextureExternalAdaptorFixture, change_name) { | ||
auto texture = create<raco::user_types::TextureExternal>("test"); | ||
|
||
dispatch(); | ||
{ | ||
auto engineSamplers{select<ramses::TextureSamplerExternal>(*sceneContext.scene(), ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal)}; | ||
EXPECT_EQ(engineSamplers.size(), 1); | ||
EXPECT_STREQ("test", engineSamplers[0]->getName()); | ||
} | ||
|
||
commandInterface.set({texture, &raco::user_types::TextureExternal::objectName_}, std::string("newName")); | ||
|
||
dispatch(); | ||
{ | ||
auto engineSamplers{select<ramses::TextureSamplerExternal>(*sceneContext.scene(), ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal)}; | ||
EXPECT_EQ(engineSamplers.size(), 1); | ||
EXPECT_STREQ("newName", engineSamplers[0]->getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.