mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
rename spine_model to spine
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include "assets/shader_asset.hpp"
|
||||
#include "assets/shape_asset.hpp"
|
||||
#include "assets/sound_asset.hpp"
|
||||
#include "assets/spine_model_asset.hpp"
|
||||
#include "assets/spine_asset.hpp"
|
||||
#include "assets/sprite_asset.hpp"
|
||||
#include "assets/text_asset.hpp"
|
||||
#include "assets/texture_asset.hpp"
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "node.hpp"
|
||||
#include "node.inl"
|
||||
#include "prefab.hpp"
|
||||
#include "spine.hpp"
|
||||
#include "sprite.hpp"
|
||||
#include "starter.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace e2d
|
||||
class shader_asset;
|
||||
class shape_asset;
|
||||
class sound_asset;
|
||||
class spine_model_asset;
|
||||
class spine_asset;
|
||||
class sprite_asset;
|
||||
class text_asset;
|
||||
class texture_asset;
|
||||
@@ -74,6 +74,7 @@ namespace e2d
|
||||
class model;
|
||||
class node;
|
||||
class prefab;
|
||||
class spine;
|
||||
class sprite;
|
||||
class starter;
|
||||
class world;
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../library.hpp"
|
||||
#include "../spine_model.hpp"
|
||||
#include "../spine.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class spine_model_asset final : public content_asset<spine_model_asset, spine_model> {
|
||||
class spine_asset final : public content_asset<spine_asset, spine> {
|
||||
public:
|
||||
static const char* type_name() noexcept { return "spine_model_asset"; }
|
||||
static const char* type_name() noexcept { return "spine_asset"; }
|
||||
static load_async_result load_async(const library& library, str_view address);
|
||||
};
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/spine_asset.hpp"
|
||||
#include "../assets/material_asset.hpp"
|
||||
#include "../assets/spine_model_asset.hpp"
|
||||
|
||||
struct spSkeleton;
|
||||
struct spSkeletonClipping;
|
||||
@@ -32,13 +32,14 @@ namespace e2d
|
||||
using animation_ptr = std::shared_ptr<spAnimationState>;
|
||||
public:
|
||||
spine_player() = default;
|
||||
spine_player(const spine_model_asset::ptr& model);
|
||||
spine_player(const spine_asset::ptr& spine);
|
||||
|
||||
spine_player& model(
|
||||
const spine_model_asset::ptr& value);
|
||||
spine_player& spine(
|
||||
const spine_asset::ptr& value);
|
||||
|
||||
spine_player& materials(
|
||||
flat_map<str_hash, material_asset::ptr>&& value) noexcept;
|
||||
|
||||
spine_player& materials(
|
||||
const flat_map<str_hash, material_asset::ptr>& value);
|
||||
|
||||
@@ -48,18 +49,18 @@ namespace e2d
|
||||
bool has_skin(const str& name) const noexcept;
|
||||
bool has_animation(const str& name) const noexcept;
|
||||
|
||||
const spine_asset::ptr& spine() const noexcept;
|
||||
const clipping_ptr& clipper() const noexcept;
|
||||
const skeleton_ptr& skeleton() const noexcept;
|
||||
const animation_ptr& animation() const noexcept;
|
||||
const spine_model_asset::ptr& model() const noexcept;
|
||||
|
||||
material_asset::ptr find_material(str_hash name) const noexcept;
|
||||
const flat_map<str_hash, material_asset::ptr>& materials() const noexcept;
|
||||
private:
|
||||
spine_asset::ptr spine_;
|
||||
clipping_ptr clipping_;
|
||||
skeleton_ptr skeleton_;
|
||||
animation_ptr animation_;
|
||||
spine_model_asset::ptr model_;
|
||||
flat_map<str_hash, material_asset::ptr> materials_;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,39 +14,39 @@ struct spAnimationStateData;
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class bad_spine_model_access final : public exception {
|
||||
class bad_spine_access final : public exception {
|
||||
public:
|
||||
const char* what() const noexcept final {
|
||||
return "bad spine model access";
|
||||
return "bad spine access";
|
||||
}
|
||||
};
|
||||
|
||||
class spine_model final {
|
||||
class spine final {
|
||||
public:
|
||||
using atlas_ptr = std::shared_ptr<spAtlas>;
|
||||
using skeleton_data_ptr = std::shared_ptr<spSkeletonData>;
|
||||
using animation_data_ptr = std::shared_ptr<spAnimationStateData>;
|
||||
public:
|
||||
spine_model() = default;
|
||||
~spine_model() noexcept = default;
|
||||
spine() = default;
|
||||
~spine() noexcept = default;
|
||||
|
||||
spine_model(spine_model&& other) noexcept;
|
||||
spine_model& operator=(spine_model&& other) noexcept;
|
||||
spine(spine&& other) noexcept;
|
||||
spine& operator=(spine&& other) noexcept;
|
||||
|
||||
spine_model(const spine_model& other);
|
||||
spine_model& operator=(const spine_model& other);
|
||||
spine(const spine& other);
|
||||
spine& operator=(const spine& other);
|
||||
|
||||
void clear() noexcept;
|
||||
void swap(spine_model& other) noexcept;
|
||||
void swap(spine& other) noexcept;
|
||||
|
||||
spine_model& assign(spine_model&& other) noexcept;
|
||||
spine_model& assign(const spine_model& other);
|
||||
spine& assign(spine&& other) noexcept;
|
||||
spine& assign(const spine& other);
|
||||
|
||||
spine_model& set_atlas(atlas_ptr atlas);
|
||||
spine_model& set_skeleton(skeleton_data_ptr skeleton);
|
||||
spine& set_atlas(atlas_ptr atlas);
|
||||
spine& set_skeleton(skeleton_data_ptr skeleton);
|
||||
|
||||
spine_model& set_default_mix(secf duration);
|
||||
spine_model& set_animation_mix(
|
||||
spine& set_default_mix(secf duration);
|
||||
spine& set_animation_mix(
|
||||
const str& from,
|
||||
const str& to,
|
||||
secf duration);
|
||||
@@ -60,7 +60,7 @@ namespace e2d
|
||||
animation_data_ptr animation_;
|
||||
};
|
||||
|
||||
void swap(spine_model& l, spine_model& r) noexcept;
|
||||
bool operator==(const spine_model& l, const spine_model& r) noexcept;
|
||||
bool operator!=(const spine_model& l, const spine_model& r) noexcept;
|
||||
void swap(spine& l, spine& r) noexcept;
|
||||
bool operator==(const spine& l, const spine& r) noexcept;
|
||||
bool operator!=(const spine& l, const spine& r) noexcept;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"prototype" : "spine_prefab.json",
|
||||
"components" : {
|
||||
"spine_player" : {
|
||||
"model" : "../spines/coin_spine.json"
|
||||
"spine" : "../spines/coin_spine.json"
|
||||
},
|
||||
"spine_player_cmd" : {
|
||||
"commands" : [{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"prototype" : "spine_prefab.json",
|
||||
"components" : {
|
||||
"spine_player" : {
|
||||
"model" : "../spines/dragon_spine.json"
|
||||
"spine" : "../spines/dragon_spine.json"
|
||||
},
|
||||
"spine_player_cmd" : {
|
||||
"commands" : [{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"prototype" : "spine_prefab.json",
|
||||
"components" : {
|
||||
"spine_player" : {
|
||||
"model" : "../spines/raptor_spine.json"
|
||||
"spine" : "../spines/raptor_spine.json"
|
||||
},
|
||||
"spine_player_cmd" : {
|
||||
"commands" : [{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/assets/spine_model_asset.hpp>
|
||||
#include <enduro2d/high/assets/spine_asset.hpp>
|
||||
|
||||
#include <enduro2d/high/assets/json_asset.hpp>
|
||||
#include <enduro2d/high/assets/binary_asset.hpp>
|
||||
@@ -17,13 +17,13 @@ namespace
|
||||
{
|
||||
using namespace e2d;
|
||||
|
||||
class spine_model_asset_loading_exception final : public asset_loading_exception {
|
||||
class spine_asset_loading_exception final : public asset_loading_exception {
|
||||
const char* what() const noexcept final {
|
||||
return "spine model asset loading exception";
|
||||
return "spine asset loading exception";
|
||||
}
|
||||
};
|
||||
|
||||
const char* spine_model_asset_schema_source = R"json({
|
||||
const char* spine_asset_schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [ "atlas", "skeleton" ],
|
||||
"additionalProperties" : false,
|
||||
@@ -52,16 +52,16 @@ namespace
|
||||
}
|
||||
})json";
|
||||
|
||||
const rapidjson::SchemaDocument& spine_model_asset_schema() {
|
||||
const rapidjson::SchemaDocument& spine_asset_schema() {
|
||||
static std::mutex mutex;
|
||||
static std::unique_ptr<rapidjson::SchemaDocument> schema;
|
||||
|
||||
std::lock_guard<std::mutex> guard(mutex);
|
||||
if ( !schema ) {
|
||||
rapidjson::Document doc;
|
||||
if ( doc.Parse(spine_model_asset_schema_source).HasParseError() ) {
|
||||
the<debug>().error("SPINE: Failed to parse spine model asset schema");
|
||||
throw spine_model_asset_loading_exception();
|
||||
if ( doc.Parse(spine_asset_schema_source).HasParseError() ) {
|
||||
the<debug>().error("ASSETS: Failed to parse spine asset schema");
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
json_utils::add_common_schema_definitions(doc);
|
||||
schema = std::make_unique<rapidjson::SchemaDocument>(doc);
|
||||
@@ -82,19 +82,19 @@ namespace
|
||||
E2D_ASSERT(root.HasMember("from") && root["from"].IsString());
|
||||
if ( !json_utils::try_parse_value(root["from"], mix.from) ) {
|
||||
the<debug>().error("SPINE: Incorrect formating of 'from' property");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
E2D_ASSERT(root.HasMember("to") && root["to"].IsString());
|
||||
if ( !json_utils::try_parse_value(root["to"], mix.to) ) {
|
||||
the<debug>().error("SPINE: Incorrect formating of 'to' property");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
E2D_ASSERT(root.HasMember("duration") && root["duration"].IsNumber());
|
||||
if ( !json_utils::try_parse_value(root["duration"], mix.duration) ) {
|
||||
the<debug>().error("SPINE: Incorrect formating of 'duration' property");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
return mix;
|
||||
@@ -105,7 +105,7 @@ namespace
|
||||
asset_dependencies loading;
|
||||
};
|
||||
|
||||
stdex::promise<spine_model::atlas_ptr> load_atlas(
|
||||
stdex::promise<spine::atlas_ptr> load_atlas(
|
||||
const library& library,
|
||||
const str& parent_address,
|
||||
const str& atlas_address)
|
||||
@@ -120,7 +120,7 @@ namespace
|
||||
](const binary_asset::load_result& atlas_data){
|
||||
auto atlas_internal = std::make_unique<atlas_internal_state>();
|
||||
|
||||
spine_model::atlas_ptr atlas(
|
||||
spine::atlas_ptr atlas(
|
||||
spAtlas_create(
|
||||
reinterpret_cast<const char*>(atlas_data->content().data()),
|
||||
math::numeric_cast<int>(atlas_data->content().size()),
|
||||
@@ -130,7 +130,7 @@ namespace
|
||||
|
||||
if ( !atlas ) {
|
||||
the<debug>().error("SPINE: Failed to create preload atlas");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
return stdex::make_tuple_promise(std::make_tuple(
|
||||
@@ -146,7 +146,7 @@ namespace
|
||||
auto atlas_internal = std::make_unique<atlas_internal_state>();
|
||||
atlas_internal->loaded = std::get<0>(results);
|
||||
|
||||
spine_model::atlas_ptr atlas(
|
||||
spine::atlas_ptr atlas(
|
||||
spAtlas_create(
|
||||
reinterpret_cast<const char*>(std::get<1>(results)->content().data()),
|
||||
math::numeric_cast<int>(std::get<1>(results)->content().size()),
|
||||
@@ -156,13 +156,13 @@ namespace
|
||||
|
||||
if ( !atlas ) {
|
||||
the<debug>().error("SPINE: Failed to create preloaded atlas");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
for ( const spAtlasPage* page = atlas->pages; page; page = page->next ) {
|
||||
if ( !page->rendererObject ) {
|
||||
the<debug>().error("SPINE: Failed to create preloaded atlas");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,12 +171,12 @@ namespace
|
||||
});
|
||||
}
|
||||
|
||||
stdex::promise<spine_model::skeleton_data_ptr> load_skeleton_data(
|
||||
stdex::promise<spine::skeleton_data_ptr> load_skeleton_data(
|
||||
const library& library,
|
||||
const str& parent_address,
|
||||
const str& skeleton_address,
|
||||
f32 skeleton_scale,
|
||||
const spine_model::atlas_ptr& atlas)
|
||||
const spine::atlas_ptr& atlas)
|
||||
{
|
||||
return library.load_asset_async<binary_asset>(
|
||||
path::combine(parent_address, skeleton_address))
|
||||
@@ -196,12 +196,12 @@ namespace
|
||||
|
||||
if ( !binary_skeleton ) {
|
||||
the<debug>().error("SPINE: Failed to create binary skeleton");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
binary_skeleton->scale = skeleton_scale;
|
||||
|
||||
spine_model::skeleton_data_ptr data_skeleton(
|
||||
spine::skeleton_data_ptr data_skeleton(
|
||||
spSkeletonBinary_readSkeletonData(
|
||||
binary_skeleton.get(),
|
||||
reinterpret_cast<const unsigned char*>(skeleton_data->content().data()),
|
||||
@@ -212,7 +212,7 @@ namespace
|
||||
the<debug>().error("SPINE: Failed to read binary skeleton data:\n"
|
||||
"--> Error: %0",
|
||||
binary_skeleton->error);
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
return data_skeleton;
|
||||
@@ -227,12 +227,12 @@ namespace
|
||||
|
||||
if ( !json_skeleton ) {
|
||||
the<debug>().error("SPINE: Failed to create json skeleton");
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
json_skeleton->scale = skeleton_scale;
|
||||
|
||||
spine_model::skeleton_data_ptr data_skeleton(
|
||||
spine::skeleton_data_ptr data_skeleton(
|
||||
spSkeletonJson_readSkeletonData(
|
||||
json_skeleton.get(),
|
||||
reinterpret_cast<const char*>(skeleton_data->content().data())),
|
||||
@@ -242,7 +242,7 @@ namespace
|
||||
the<debug>().error("SPINE: Failed to read json skeleton data:\n"
|
||||
"--> Error: %0",
|
||||
json_skeleton->error);
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
}
|
||||
|
||||
return data_skeleton;
|
||||
@@ -250,7 +250,7 @@ namespace
|
||||
});
|
||||
}
|
||||
|
||||
stdex::promise<spine_model> parse_spine_model(
|
||||
stdex::promise<spine> parse_spine(
|
||||
const library& library,
|
||||
const str& parent_address,
|
||||
const rapidjson::Value& root)
|
||||
@@ -297,7 +297,7 @@ namespace
|
||||
atlas_address,
|
||||
skeleton_scale,
|
||||
skeleton_address
|
||||
](const spine_model::atlas_ptr& atlas){
|
||||
](const spine::atlas_ptr& atlas){
|
||||
return stdex::make_tuple_promise(std::make_tuple(
|
||||
stdex::make_resolved_promise(atlas),
|
||||
load_skeleton_data(
|
||||
@@ -311,10 +311,10 @@ namespace
|
||||
default_animation_mix,
|
||||
animation_mixes = std::move(animation_mixes)
|
||||
](const std::tuple<
|
||||
spine_model::atlas_ptr,
|
||||
spine_model::skeleton_data_ptr
|
||||
spine::atlas_ptr,
|
||||
spine::skeleton_data_ptr
|
||||
>& results){
|
||||
spine_model content;
|
||||
spine content;
|
||||
content.set_atlas(std::get<0>(results));
|
||||
content.set_skeleton(std::get<1>(results));
|
||||
content.set_default_mix(default_animation_mix);
|
||||
@@ -328,7 +328,7 @@ namespace
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
spine_model_asset::load_async_result spine_model_asset::load_async(
|
||||
spine_asset::load_async_result spine_asset::load_async(
|
||||
const library& library, str_view address)
|
||||
{
|
||||
return library.load_asset_async<json_asset>(address)
|
||||
@@ -339,7 +339,7 @@ namespace e2d
|
||||
](const json_asset::load_result& spine_data){
|
||||
return the<deferrer>().do_in_worker_thread([address, spine_data](){
|
||||
const rapidjson::Document& doc = *spine_data->content();
|
||||
rapidjson::SchemaValidator validator(spine_model_asset_schema());
|
||||
rapidjson::SchemaValidator validator(spine_asset_schema());
|
||||
|
||||
if ( doc.Accept(validator) ) {
|
||||
return;
|
||||
@@ -358,14 +358,14 @@ namespace e2d
|
||||
the<debug>().error("ASSET: Failed to validate asset json");
|
||||
}
|
||||
|
||||
throw spine_model_asset_loading_exception();
|
||||
throw spine_asset_loading_exception();
|
||||
})
|
||||
.then([&library, parent_address, spine_data](){
|
||||
return parse_spine_model(
|
||||
return parse_spine(
|
||||
library, parent_address, *spine_data->content());
|
||||
})
|
||||
.then([](auto&& content){
|
||||
return spine_model_asset::create(
|
||||
return spine_asset::create(
|
||||
std::forward<decltype(content)>(content));
|
||||
});
|
||||
});
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
spine_player::spine_player(const spine_model_asset::ptr& model) {
|
||||
this->model(model);
|
||||
spine_player::spine_player(const spine_asset::ptr& spine) {
|
||||
this->spine(spine);
|
||||
}
|
||||
|
||||
spine_player& spine_player::model(const spine_model_asset::ptr& value) {
|
||||
spine_player& spine_player::spine(const spine_asset::ptr& value) {
|
||||
clipping_ptr new_clipping = clipping_ptr(
|
||||
spSkeletonClipping_create(),
|
||||
spSkeletonClipping_dispose);
|
||||
@@ -42,7 +42,7 @@ namespace e2d
|
||||
}
|
||||
}
|
||||
|
||||
model_ = value;
|
||||
spine_ = value;
|
||||
clipping_ = std::move(new_clipping);
|
||||
skeleton_ = std::move(new_skeleton);
|
||||
animation_ = std::move(new_animation);
|
||||
@@ -78,15 +78,19 @@ namespace e2d
|
||||
}
|
||||
|
||||
bool spine_player::has_skin(const str& name) const noexcept {
|
||||
return model_
|
||||
&& model()->content().skeleton()
|
||||
&& spSkeletonData_findSkin(model()->content().skeleton().get(), name.c_str());
|
||||
return spine_
|
||||
&& spine()->content().skeleton()
|
||||
&& spSkeletonData_findSkin(spine()->content().skeleton().get(), name.c_str());
|
||||
}
|
||||
|
||||
bool spine_player::has_animation(const str& name) const noexcept {
|
||||
return model_
|
||||
&& model()->content().skeleton()
|
||||
&& spSkeletonData_findAnimation(model()->content().skeleton().get(), name.c_str());
|
||||
return spine_
|
||||
&& spine()->content().skeleton()
|
||||
&& spSkeletonData_findAnimation(spine()->content().skeleton().get(), name.c_str());
|
||||
}
|
||||
|
||||
const spine_asset::ptr& spine_player::spine() const noexcept {
|
||||
return spine_;
|
||||
}
|
||||
|
||||
const spine_player::clipping_ptr& spine_player::clipper() const noexcept {
|
||||
@@ -101,10 +105,6 @@ namespace e2d
|
||||
return animation_;
|
||||
}
|
||||
|
||||
const spine_model_asset::ptr& spine_player::model() const noexcept {
|
||||
return model_;
|
||||
}
|
||||
|
||||
material_asset::ptr spine_player::find_material(str_hash name) const noexcept {
|
||||
const auto iter = materials_.find(name);
|
||||
return iter != materials_.end()
|
||||
@@ -124,7 +124,7 @@ namespace e2d
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"model" : { "$ref": "#/common_definitions/address" },
|
||||
"spine" : { "$ref": "#/common_definitions/address" },
|
||||
"materials" : { "$ref": "#/definitions/materials" },
|
||||
"skin" : { "$ref": "#/common_definitions/name" },
|
||||
"attachments" : { "$ref": "#/definitions/attachments" }
|
||||
@@ -161,18 +161,18 @@ namespace e2d
|
||||
spine_player& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("model") ) {
|
||||
auto model = ctx.dependencies.find_asset<spine_model_asset>(
|
||||
path::combine(ctx.parent_address, ctx.root["model"].GetString()));
|
||||
if ( !model ) {
|
||||
the<debug>().error("SPINE_PLAYER: Dependency 'model' is not found:\n"
|
||||
if ( ctx.root.HasMember("spine") ) {
|
||||
auto spine = ctx.dependencies.find_asset<spine_asset>(
|
||||
path::combine(ctx.parent_address, ctx.root["spine"].GetString()));
|
||||
if ( !spine ) {
|
||||
the<debug>().error("SPINE_PLAYER: Dependency 'spine' is not found:\n"
|
||||
"--> Parent address: %0\n"
|
||||
"--> Dependency address: %1",
|
||||
ctx.parent_address,
|
||||
ctx.root["model"].GetString());
|
||||
ctx.root["spine"].GetString());
|
||||
return false;
|
||||
}
|
||||
component.model(model);
|
||||
component.spine(spine);
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("materials") ) {
|
||||
@@ -252,9 +252,9 @@ namespace e2d
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("model") ) {
|
||||
dependencies.add_dependency<spine_model_asset>(
|
||||
path::combine(ctx.parent_address, ctx.root["model"].GetString()));
|
||||
if ( ctx.root.HasMember("spine") ) {
|
||||
dependencies.add_dependency<spine_asset>(
|
||||
path::combine(ctx.parent_address, ctx.root["spine"].GetString()));
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("materials") ) {
|
||||
|
||||
@@ -4,42 +4,42 @@
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/spine_model.hpp>
|
||||
#include <enduro2d/high/spine.hpp>
|
||||
|
||||
#include <spine/spine.h>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
spine_model::spine_model(spine_model&& other) noexcept {
|
||||
spine::spine(spine&& other) noexcept {
|
||||
assign(std::move(other));
|
||||
}
|
||||
|
||||
spine_model& spine_model::operator=(spine_model&& other) noexcept {
|
||||
spine& spine::operator=(spine&& other) noexcept {
|
||||
return assign(std::move(other));
|
||||
}
|
||||
|
||||
spine_model::spine_model(const spine_model& other) {
|
||||
spine::spine(const spine& other) {
|
||||
assign(other);
|
||||
}
|
||||
|
||||
spine_model& spine_model::operator=(const spine_model& other) {
|
||||
spine& spine::operator=(const spine& other) {
|
||||
return assign(other);
|
||||
}
|
||||
|
||||
void spine_model::clear() noexcept {
|
||||
void spine::clear() noexcept {
|
||||
atlas_.reset();
|
||||
skeleton_.reset();
|
||||
animation_.reset();
|
||||
}
|
||||
|
||||
void spine_model::swap(spine_model& other) noexcept {
|
||||
void spine::swap(spine& other) noexcept {
|
||||
using std::swap;
|
||||
swap(atlas_, other.atlas_);
|
||||
swap(skeleton_, other.skeleton_);
|
||||
swap(animation_, other.animation_);
|
||||
}
|
||||
|
||||
spine_model& spine_model::assign(spine_model&& other) noexcept {
|
||||
spine& spine::assign(spine&& other) noexcept {
|
||||
if ( this != &other ) {
|
||||
swap(other);
|
||||
other.clear();
|
||||
@@ -47,9 +47,9 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
spine_model& spine_model::assign(const spine_model& other) {
|
||||
spine& spine::assign(const spine& other) {
|
||||
if ( this != &other ) {
|
||||
spine_model m;
|
||||
spine m;
|
||||
m.atlas_ = other.atlas_;
|
||||
m.skeleton_ = other.skeleton_;
|
||||
m.animation_ = other.animation_;
|
||||
@@ -58,12 +58,12 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
spine_model& spine_model::set_atlas(atlas_ptr atlas) {
|
||||
spine& spine::set_atlas(atlas_ptr atlas) {
|
||||
atlas_ = std::move(atlas);
|
||||
return *this;
|
||||
}
|
||||
|
||||
spine_model& spine_model::set_skeleton(skeleton_data_ptr skeleton) {
|
||||
spine& spine::set_skeleton(skeleton_data_ptr skeleton) {
|
||||
animation_data_ptr animation;
|
||||
if ( skeleton ) {
|
||||
animation.reset(
|
||||
@@ -78,15 +78,15 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
spine_model& spine_model::set_default_mix(secf duration) {
|
||||
spine& spine::set_default_mix(secf duration) {
|
||||
if ( !animation_ ) {
|
||||
throw bad_spine_model_access();
|
||||
throw bad_spine_access();
|
||||
}
|
||||
animation_->defaultMix = duration.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
spine_model& spine_model::set_animation_mix(
|
||||
spine& spine::set_animation_mix(
|
||||
const str& from,
|
||||
const str& to,
|
||||
secf duration)
|
||||
@@ -100,39 +100,39 @@ namespace e2d
|
||||
: nullptr;
|
||||
|
||||
if ( !from_anim || !to_anim ) {
|
||||
throw bad_spine_model_access();
|
||||
throw bad_spine_access();
|
||||
}
|
||||
|
||||
spAnimationStateData_setMix(animation_.get(), from_anim, to_anim, duration.value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const spine_model::atlas_ptr& spine_model::atlas() const noexcept {
|
||||
const spine::atlas_ptr& spine::atlas() const noexcept {
|
||||
return atlas_;
|
||||
}
|
||||
|
||||
const spine_model::skeleton_data_ptr& spine_model::skeleton() const noexcept {
|
||||
const spine::skeleton_data_ptr& spine::skeleton() const noexcept {
|
||||
return skeleton_;
|
||||
}
|
||||
|
||||
const spine_model::animation_data_ptr& spine_model::animation() const noexcept {
|
||||
const spine::animation_data_ptr& spine::animation() const noexcept {
|
||||
return animation_;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
void swap(spine_model& l, spine_model& r) noexcept {
|
||||
void swap(spine& l, spine& r) noexcept {
|
||||
l.swap(r);
|
||||
}
|
||||
|
||||
bool operator==(const spine_model& l, const spine_model& r) noexcept {
|
||||
bool operator==(const spine& l, const spine& r) noexcept {
|
||||
return l.atlas() == r.atlas()
|
||||
&& l.skeleton() == r.skeleton()
|
||||
&& l.animation() == r.animation();
|
||||
}
|
||||
|
||||
bool operator!=(const spine_model& l, const spine_model& r) noexcept {
|
||||
bool operator!=(const spine& l, const spine& r) noexcept {
|
||||
return !(l == r);
|
||||
}
|
||||
}
|
||||
@@ -35,10 +35,10 @@ TEST_CASE("render"){
|
||||
}
|
||||
{
|
||||
const auto ss = render::sampler_state()
|
||||
.wrap(render::sampler_wrap::clamp)
|
||||
.wrap(render::sampler_wrap::clamp, render::sampler_wrap::mirror)
|
||||
.filter(render::sampler_min_filter::linear, render::sampler_mag_filter::nearest);
|
||||
REQUIRE(ss.s_wrap() == render::sampler_wrap::clamp);
|
||||
REQUIRE(ss.t_wrap() == render::sampler_wrap::clamp);
|
||||
REQUIRE(ss.t_wrap() == render::sampler_wrap::mirror);
|
||||
REQUIRE(ss.min_filter() == render::sampler_min_filter::linear);
|
||||
REQUIRE(ss.mag_filter() == render::sampler_mag_filter::nearest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user