Changeset 33

Show
Ignore:
Timestamp:
03/05/09 19:19:26 (3 years ago)
Author:
JarrettBillingsley
Message:

blaaaah

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/nonagon/node.d

    r32 r33  
    2626    protected Matrix mMatGlobal; 
    2727    protected Matrix mMatRotation; 
     28    protected bool mMatDirty; 
    2829 
    2930    protected Node mParent; 
    30     protected Node[] mChildren; 
     31    protected Node mSibling; 
     32    protected Node mChild; 
    3133    protected char[] mName; 
    32     protected bool mMatDirty; 
    3334 
    3435    // ================================================================================================================================================ 
     
    614615 
    615616    /** 
    616     Returns: 
    617         The Node's current parent. 
     617    Gets this node's parent, or null if it has none. 
    618618    */ 
    619619    Node parent() 
    620620    { 
    621621        return mParent; 
     622    } 
     623 
     624    /** 
     625    Gets this node's next sibling, or null if it has none.  You cannot set siblings, only parents. 
     626    */ 
     627    Node sibling() 
     628    { 
     629        return mSibling; 
     630    } 
     631 
     632    /** 
     633    Gets this node's first child, or null if it has no children.  You cannot set children, only 
     634    parents. 
     635    */ 
     636    Node child() 
     637    { 
     638        return mChild; 
    622639    } 
    623640 
     
    634651    int opApply(int delegate(ref Node) dg) 
    635652    { 
    636         foreach(n; mChildren
     653        for(auto n = mChild; n !is null; n = n.mSibling
    637654            if(auto result = dg(n)) 
    638655                return result; 
     
    653670    int opApply(int delegate(ref uword i, ref Node) dg) 
    654671    { 
    655         foreach(i, n; mChildren) 
     672        uword i = 0; 
     673 
     674        for(auto n = mChild; n !is null; n = n.mSibling, i++) 
    656675            if(auto result = dg(i, n)) 
    657676                return result; 
     
    680699        if(recursive) 
    681700        { 
    682             foreach(n; mChildren
     701            for(auto n = mChild; n !is null; n = n.mSibling
    683702            { 
    684703                if(n.name == name) 
     
    691710        else 
    692711        { 
    693             foreach(n; mChildren
     712            for(auto n = mChild; n !is null; n = n.mSibling
    694713                if(n.name == name) 
    695714                    return n; 
     
    732751    protected void addChild(Node c) 
    733752    { 
    734         debug foreach(child; mChildren) assert(c !is child); 
    735         mChildren ~= c; 
     753        debug for(auto n = mChild; n !is null; n = n.mSibling) assert(c !is n); 
     754         
     755        c.mSibling = mChild; 
     756        mChild = c; 
    736757    } 
    737758 
    738759    protected void removeChild(Node c) 
    739760    { 
    740         foreach(i, child; mChildren
     761        if(c is mChild
    741762        { 
    742             if(c is child) 
     763            mChild = c.mSibling; 
     764            return; 
     765        } 
     766        else 
     767        { 
     768            for(auto n = mChild; n !is null; n = n.mSibling) 
    743769            { 
    744                 mChildren[i] = mChildren[$ - 1]; 
    745                 mChildren.length = mChildren.length - 1; 
    746                 return; 
     770                if(c.mSibling is n) 
     771                { 
     772                    c.mSibling = n.mSibling; 
     773                    return; 
     774                } 
    747775            } 
    748776        } 
     
    755783        mMatDirty = true; 
    756784 
    757         foreach(Node n; mChildren
     785        for(auto n = mChild; n !is null; n = n.mSibling
    758786            n.matNeedsUpdate(); 
    759787    } 
     
    764792            updateMatrixSolo(); 
    765793 
    766         foreach(Node n; mChildren
     794        for(auto n = mChild; n !is null; n = n.mSibling
    767795            n.updateMatrix(); 
    768796    } 
  • trunk/test.d

    r32 r33  
    88 
    99import nonagon.node; 
     10 
     11import derelict.openal.al; 
     12 
     13char[][] fromStringsz(char* s) 
     14{ 
     15    char[][] ret; 
     16     
     17    while(*s != '\0') 
     18    { 
     19        ret ~= fromStringz(s); 
     20        s += ret[$ - 1].length + 1; 
     21    } 
     22 
     23    return ret; 
     24} 
    1025 
    1126void main() 
     
    2237    }; 
    2338 
     39    DerelictAL.load(); 
     40    auto device = alcOpenDevice(null); // open default device 
     41    auto context = alcCreateContext(device, null); // create context 
     42    alcMakeContextCurrent(context); // set active context 
     43 
     44    Stdout.formatln("ALC:"); 
     45    Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER))); 
     46    Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_DEVICE_SPECIFIER))); 
     47    Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_EXTENSIONS))); 
     48    Stdout.formatln("{}", fromStringsz(alcGetString(null, ALC_DEVICE_SPECIFIER))); 
     49//  Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER))); 
     50//  Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_CAPTURE_DEVICE_SPECIFIER))); 
     51 
     52    Stdout.formatln("\nAL:"); 
     53    Stdout.formatln("{}", fromStringz(alGetString(AL_VERSION))); 
     54    Stdout.formatln("{}", fromStringz(alGetString(AL_RENDERER))); 
     55    Stdout.formatln("{}", fromStringz(alGetString(AL_VENDOR))); 
     56    Stdout.formatln("{}", fromStringz(alGetString(AL_EXTENSIONS))); 
     57 
    2458    while(!quit) 
    2559        Window.update(); 
     60         
     61    alcDestroyContext(context); 
     62    alcCloseDevice(device); 
    2663} 
     64 
     65import tango.stdc.stringz;