Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski  leszek@koltunski.pl                                          //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// 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
//                                                                                               //
11
// This library is distributed in the hope that it will be useful,                               //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                             //
14
// Lesser General Public License for more details.                                               //
15
//                                                                                               //
16
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
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
class InternalNodeData
30
  {
31
  private final ArrayList<Long> mKey;
32
  private int numPointingNodes;
33
  private long currTime;
34

    
35
  final long ID;
36
  DistortedFramebuffer mFBO;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  InternalNodeData(long id, ArrayList<Long> k)
41
    {
42
    ID              = id;
43
    mKey            = k;
44
    numPointingNodes= 1;
45
    currTime        =-1;
46
    mFBO            = null;
47
    }
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  static InternalNodeData returnData(ArrayList<Long> list)
52
    {
53
    InternalNodeData data = InternalStackFrameList.getMapID(list);
54

    
55
    if( data!=null )
56
      {
57
      data.numPointingNodes++;
58
      }
59
    else
60
      {
61
      data = InternalStackFrameList.putNewDataToMap(list);
62
      }
63

    
64
    return data;
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  boolean removeData()
70
    {
71
    if( --numPointingNodes==0 )
72
      {
73
      InternalStackFrameList.removeKeyFromMap(mKey);
74

    
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
  }
(10-10/17)