1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2019 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// 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
|
// Distorted 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 //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
class InternalNodeData
|
29
|
{
|
30
|
private final ArrayList<Long> mKey;
|
31
|
private int numPointingNodes;
|
32
|
private long currTime;
|
33
|
|
34
|
final long ID;
|
35
|
DistortedFramebuffer mFBO;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
InternalNodeData(long id, ArrayList<Long> k)
|
40
|
{
|
41
|
ID = id;
|
42
|
mKey = k;
|
43
|
numPointingNodes= 1;
|
44
|
currTime =-1;
|
45
|
mFBO = null;
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
static InternalNodeData returnData(ArrayList<Long> list)
|
51
|
{
|
52
|
InternalNodeData data = InternalStackFrameList.getMapID(list);
|
53
|
|
54
|
if( data!=null )
|
55
|
{
|
56
|
data.numPointingNodes++;
|
57
|
}
|
58
|
else
|
59
|
{
|
60
|
data = InternalStackFrameList.putNewDataToMap(list);
|
61
|
}
|
62
|
|
63
|
return data;
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
|
68
|
boolean removeData()
|
69
|
{
|
70
|
if( --numPointingNodes==0 )
|
71
|
{
|
72
|
InternalStackFrameList.removeKeyFromMap(mKey);
|
73
|
|
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
|
}
|