Skip to content

Commit

Permalink
first integration attempt 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
aconstlink committed Nov 1, 2024
1 parent 7ac9a57 commit 4871aec
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 2 deletions.
7 changes: 6 additions & 1 deletion scene/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ set( sources
"visitor/render_visitor.cpp"
"visitor/trafo_visitor.h"
"visitor/trafo_visitor.cpp"
"visitor/variable_update_visitor.h"
"visitor/variable_update_visitor.cpp"

"component/icomponent.h"
"component/code_component.h"
"component/code_component.cpp"
"component/name_component.hpp"

"component/msl_component.h"
"component/msl_component.cpp"
"component/render_state_component.h"
"component/render_state_component.cpp"

"component/render_variables_component.hpp"
"component/variables_component.hpp"
)

motor_vs_src_dir( sources )
Expand Down
2 changes: 2 additions & 0 deletions scene/component/icomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "../typedefs.h"
#include "../protos.h"

#include "../ivisitable.hpp"

namespace motor
{
namespace scene
Expand Down
Empty file.
26 changes: 26 additions & 0 deletions scene/component/variables_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


#pragma once


#include "icomponent.h"

#include "../global.h"

namespace motor
{
namespace scene
{
class variables_component : public motor::scene::icomponent
{
typedef icomponent base_t ;
motor_this_typedefs( variables_component ) ;

public:


};
motor_typedef( variables_component ) ;

}
}
4 changes: 4 additions & 0 deletions scene/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "visitor/trafo_visitor.h"
#include "visitor/log_visitor.h"
#include "visitor/render_visitor.h"
#include "visitor/variable_update_visitor.h"

using namespace motor::scene ;

Expand All @@ -35,6 +36,9 @@ void_t global::init( void_t ) noexcept
this_t::register_default_callbacks< motor::scene::render_visitor, motor::scene::trafo3d_node >() ;
this_t::register_default_callbacks< motor::scene::render_visitor, motor::scene::render_settings >() ;
this_t::register_default_callbacks< motor::scene::render_visitor, motor::scene::render_node >() ;

//this_t::register_default_callbacks< motor::scene::variable_update_visitor, motor::scene::group >() ;
//this_t::register_default_callbacks< motor::scene::variable_update_visitor, motor::scene::leaf >() ;
}

//***********************************************************************
Expand Down
2 changes: 2 additions & 0 deletions scene/ivisitable.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

#pragma once

#include "api.h"
#include "double_dispatch.h"

Expand Down
4 changes: 3 additions & 1 deletion scene/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

using namespace motor::scene ;

motor_core_dd_id_init( node ) ;

//*******************************************************************
node::traverser::traverser( node_ptr_t begin ) noexcept :_traverse( begin )
{
Expand Down Expand Up @@ -63,7 +65,7 @@ node::~node( void_t ) noexcept

//*******************************************************************
motor::scene::result node::apply( motor::scene::ivisitor_ptr_t v ) noexcept
{
{
return v->visit( this ) ;
}

Expand Down
3 changes: 3 additions & 0 deletions scene/node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "../protos.h"
#include "../ivisitable.hpp"

#include <motor/wire/variable.hpp>

#include <motor/std/vector>
#include <motor/core/double_dispatch.hpp>

Expand All @@ -16,6 +18,7 @@ namespace motor
class MOTOR_SCENE_API node : public motor::scene::ivisitable
{
motor_this_typedefs( node ) ;
motor_core_dd_id_fn() ;

private:

Expand Down
3 changes: 3 additions & 0 deletions scene/protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ namespace motor

motor_class_proto_typedefs( ivisitor ) ;
motor_class_proto_typedefs( icomponent ) ;

motor_class_proto_typedefs( variables_component ) ;
motor_class_proto_typedefs( render_variables_component ) ;
}
}
40 changes: 40 additions & 0 deletions scene/visitor/variable_update_visitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include "variable_update_visitor.h"

#include "../component/variables_component.hpp"
#include "../node/node.h"

using namespace motor::scene ;

motor_core_dd_id_init( variable_update_visitor ) ;

//*************************************************************************************************
variable_update_visitor::variable_update_visitor( void_t ) noexcept
{
}

//*************************************************************************************************
variable_update_visitor::~variable_update_visitor( void_t ) noexcept
{
}

//*************************************************************************************************
motor::scene::result variable_update_visitor::visit( motor::scene::ivisitable_ptr_t vable ) noexcept
{
if( auto * n = dynamic_cast< motor::scene::node_ptr_t >( vable ); n != nullptr )
{
auto * comp = n->borrow_component< motor::scene::variables_component_t >() ;
// make stuff with variables

return motor::scene::result::ok ;
}

//variables_component_ptr_t
return motor::scene::result::ok ;
}

//*************************************************************************************************
motor::scene::result variable_update_visitor::post_visit( motor::scene::ivisitable_ptr_t, motor::scene::result const ) noexcept
{
return motor::scene::result::ok ;
}
29 changes: 29 additions & 0 deletions scene/visitor/variable_update_visitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#pragma once

#include "ivisitor.h"

namespace motor
{
namespace scene
{
class MOTOR_SCENE_API variable_update_visitor : public ivisitor
{
motor_this_typedefs( variable_update_visitor ) ;
motor_core_dd_id_fn() ;

public:

variable_update_visitor( void_t ) noexcept ;
virtual ~variable_update_visitor( void_t ) noexcept ;

public:



virtual motor::scene::result visit( motor::scene::ivisitable_ptr_t ) noexcept ;
virtual motor::scene::result post_visit( motor::scene::ivisitable_ptr_t, motor::scene::result const ) noexcept ;
};
motor_typedef( variable_update_visitor ) ;
}
}
1 change: 1 addition & 0 deletions tool/imgui/node_kit/imgui_node_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using namespace motor::tool ;


//**************************************************************************
imgui_node_component::imgui_node_component( void_t ) noexcept
{
Expand Down
1 change: 1 addition & 0 deletions wire/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set( SOURCES ${SOURCES}
"slot/sheet.hpp"
"slot/other_slot.hpp"

"variables/variable_set.hpp"
"variables/vector_variables.hpp"
"variables/trafo_variables.hpp"
)
Expand Down
85 changes: 85 additions & 0 deletions wire/variables/variable_set.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

#pragma once

#include "../api.h"
#include "../typedefs.h"
#include "../variable.hpp"

#include <motor/std/vector>

namespace motor
{
namespace wire
{
class MOTOR_WIRE_API variable_set
{
motor_this_typedefs( variable_set ) ;

public:

using pull_data_funk_t = std::function< void_t ( void_ptr_t, motor::wire::any_ptr_t ) > ;

private:

struct per_var_data
{
pull_data_funk_t funk ;
motor::wire::any_mtr_t var ;
};
motor::vector< this_t::per_var_data > _variables ;

public:

variable_set( void_t ) noexcept {}

variable_set( this_rref_t rhv ) noexcept :
_variables( std::move( rhv._variables ) ){}

variable_set( this_cref_t ) = delete ;

~variable_set( void_t ) noexcept
{
for( auto & d : _variables ) motor::release( motor::move( d.var ) ) ;
}

public:

using for_each_variable_funk_t = std::function< void_t ( motor::wire::any_mtr_t ) > ;

void_t for_each( for_each_variable_funk_t funk ) noexcept
{
for( auto & d : _variables )
{
funk( d.var ) ;
}
}

// call the pull function for each variable
template< typename T >
void_t pull_from_each( T * owner ) noexcept
{
for( auto & d : _variables )
{
d.funk( reinterpret_cast< void_ptr_t >( owner ), d.var ) ;
}
}

public:

// add a variable which should interface with some other variable
// the pull function allows to "pull" the data from the any variable
// and update the other variable which is not interfaceable.
void_t add_variable( pull_data_funk_t funk, motor::wire::any_mtr_safe_t v ) noexcept
{
for( auto & d : _variables )
if( d.var == v )
{
motor::release( v ) ;
return ;
}

_variables.emplace_back( this_t::per_var_data { funk, motor::move( v ) } ) ;
}
};
}
}

0 comments on commit 4871aec

Please sign in to comment.