-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDTStructureEqualPatch.m
93 lines (73 loc) · 1.82 KB
/
DTStructureEqualPatch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#import "DTStructureEqualPatch.h"
BOOL DTStructureCompare(QCStructure* qcs1, QCStructure* qcs2)
{
NSUInteger i, count1;
if(qcs1 == qcs2)
return YES;
count1 = [qcs1 count];
if(count1 != [qcs2 count])
return NO;
Class QCStructureClass = [QCStructure class];
for(i=0; i < count1; i++)
{
if([[qcs1 keyAtIndex:i] compare:[qcs2 keyAtIndex:i]] != 0)
return NO;
id member1 = [qcs1 memberAtIndex:i];
id member2 = [qcs2 memberAtIndex:i];
if([member1 class] != [member2 class])
return NO;
if([member1 respondsToSelector:@selector(compare:)])
{
if([member1 compare:member2] != 0)
return NO;
else
continue;
}
if([member1 isKindOfClass:QCStructureClass])
{
if(!DTStructureCompare(member1, member2))
return NO;
else
continue;
}
else
{
// FIXME: Colors, Images, and Meshes might end up here -- handle someday
NSLog(NSLocalizedString(@"DTStructureEqualPatch WARNING: encountered unexpected class in a QCStructure: %@ (%@) ...comparison returned false by default.",@""), member1, [member1 className]);
return NO;
}
}
return YES;
}
@implementation DTStructureEqualPatch
+(BOOL)isSafe
{
return YES;
}
+(BOOL)allowsSubpatchesWithIdentifier:(id)identifier
{
return NO;
}
+(QCPatchExecutionMode)executionModeWithIdentifier:(id)identifier
{
return 0;
}
+(int)timeModeWithIdentifier:(id)identifier
{
return 0;
}
- (id)initWithIdentifier:(id)identifier
{
if(self = [super initWithIdentifier:identifier])
{
[[self userInfo] setObject:@"Kineme Structure Equal" forKey:@"name"];
[outputEquality setBooleanValue:TRUE];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
[outputEquality setBooleanValue:DTStructureCompare([inputStructure1 structureValue], [inputStructure2 structureValue])];
return YES;
}
@end