Project

General

Profile

Download (3.51 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / main / InternalNodeData.java @ 178983f4

1 8bfefd68 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 2e569ff6 Leszek Koltunski
// Copyright 2019 Leszek Koltunski  leszek@koltunski.pl                                          //
3 8bfefd68 Leszek Koltunski
//                                                                                               //
4 46b572b5 Leszek Koltunski
// This file is part of Distorted.                                                               //
5 8bfefd68 Leszek Koltunski
//                                                                                               //
6 2e569ff6 Leszek Koltunski
// This library is free software; you can redistribute it and/or                                 //
7
// modify it under the terms of the GNU Lesser General Public                                    //
8
// License as published by the Free Software Foundation; either                                  //
9
// version 2.1 of the License, or (at your option) any later version.                            //
10 8bfefd68 Leszek Koltunski
//                                                                                               //
11 2e569ff6 Leszek Koltunski
// This library is distributed in the hope that it will be useful,                               //
12 8bfefd68 Leszek Koltunski
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13 2e569ff6 Leszek Koltunski
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                             //
14
// Lesser General Public License for more details.                                               //
15 8bfefd68 Leszek Koltunski
//                                                                                               //
16 2e569ff6 Leszek Koltunski
// You should have received a copy of the GNU Lesser General Public                              //
17
// License along with this library; if not, write to the Free Software                           //
18
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
19 8bfefd68 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
20
21
package org.distorted.library.main;
22
23
import java.util.ArrayList;
24
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26
/**
27
 * This is a member of DistortedNode. Makes sure two isomorphic Nodes only get rendered once.
28
 */
29 7602a827 Leszek Koltunski
class InternalNodeData
30 8bfefd68 Leszek Koltunski
  {
31 3543a3cf Leszek Koltunski
  private final ArrayList<Long> mKey;
32 8bfefd68 Leszek Koltunski
  private int numPointingNodes;
33
  private long currTime;
34
35
  final long ID;
36
  DistortedFramebuffer mFBO;
37
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 3543a3cf Leszek Koltunski
  InternalNodeData(long id, ArrayList<Long> k)
41 8bfefd68 Leszek Koltunski
    {
42
    ID              = id;
43 3543a3cf Leszek Koltunski
    mKey            = k;
44 8bfefd68 Leszek Koltunski
    numPointingNodes= 1;
45
    currTime        =-1;
46
    mFBO            = null;
47
    }
48
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
51 7602a827 Leszek Koltunski
  static InternalNodeData returnData(ArrayList<Long> list)
52 8bfefd68 Leszek Koltunski
    {
53 3543a3cf Leszek Koltunski
    InternalNodeData data = InternalStackFrameList.getMapID(list);
54 8bfefd68 Leszek Koltunski
55 3543a3cf Leszek Koltunski
    if( data!=null )
56 8bfefd68 Leszek Koltunski
      {
57 3543a3cf Leszek Koltunski
      data.numPointingNodes++;
58 8bfefd68 Leszek Koltunski
      }
59
    else
60
      {
61 3543a3cf Leszek Koltunski
      data = InternalStackFrameList.putNewDataToMap(list);
62 8bfefd68 Leszek Koltunski
      }
63
64 3543a3cf Leszek Koltunski
    return data;
65 8bfefd68 Leszek Koltunski
    }
66
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69
  boolean removeData()
70
    {
71
    if( --numPointingNodes==0 )
72
      {
73 3543a3cf Leszek Koltunski
      InternalStackFrameList.removeKeyFromMap(mKey);
74 8bfefd68 Leszek Koltunski
75
      if( mFBO!=null ) return true;
76
      }
77
78
    return false;
79
    }
80
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83
  boolean notRenderedYetAtThisTime(long time)
84
    {
85
    if( currTime!=time )
86
      {
87
      currTime = time;
88
      return true;
89
      }
90
91
    return false;
92
    }
93
  }