coeng

diff src/co_xform.cc @ 6:2f872a179914

first component test: - prs, xform, physics components with dependencies - topological sort of components to update them in the correct order - debug visualization component todo: remove draw() from components, doesn't make sense
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Feb 2015 07:27:12 +0200
parents 0e5da17d589c
children 8cce82794f90
line diff
     1.1 --- a/src/co_xform.cc	Sat Feb 14 01:35:42 2015 +0200
     1.2 +++ b/src/co_xform.cc	Sat Feb 14 07:27:12 2015 +0200
     1.3 @@ -15,20 +15,28 @@
     1.4  	register_component(name, cons_xform);
     1.5  }
     1.6  
     1.7 +// ---- class CoPRS ----
     1.8 +
     1.9  CoPRS::CoPRS()
    1.10 +	: scale(1, 1, 1)
    1.11  {
    1.12  	name = "prs";
    1.13  
    1.14  	register_component(name, cons_prs);
    1.15  }
    1.16  
    1.17 -void CoPRS::update()
    1.18 +const char **CoPRS::update_before() const
    1.19 +{
    1.20 +	static const char *before[] = { "xform", 0 };
    1.21 +	return before;
    1.22 +}
    1.23 +
    1.24 +void CoPRS::update(float dt)
    1.25  {
    1.26  	if(!gobj) return;
    1.27  
    1.28  	if(!co_xform) {
    1.29 -		Component *co = gobj->get_component("xform");
    1.30 -		if(!co || !(co_xform = dynamic_cast<CoXForm*>(co))) {
    1.31 +		if(!(co_xform = COCAST(CoXForm, gobj->get_component("xform")))) {
    1.32  			assert(co_xform);
    1.33  			return;
    1.34  		}