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