CIGIPP/CollisionDetectionVolumeNotification.pm

filter: Statementstmt 64.2% 54 / 84 Branchbran 29.1% 7 / 24 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 86.6% 13 / 15 Podpod 100% 11 / 11 totaltotal 60.4% 87 / 144 CC 16 SCAR 19.1
CC
16
Cov
55%
new
19.6
unpack
6.0
byte_swap
6.0
CRAP 6.8
« CIGIPP/TerrestrialSurfaceConditionsControl.pm ↑ Summary CIGIPP/SensorResponse.pm »
1 #
2 # Rinchi Common Image Generator Interface for Perl
3 # Class Identifier: f78b3dea-200e-11de-bdd4-001c25551abc
4 # Author: Brian M. Ames
5 #
6  
7 package Rinchi::CIGIPP::CollisionDetectionVolumeNotification;
8  
9 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 require Exporter;
15  
16 2 our @ISA = qw(Exporter);
17  
18 # Items to export into callers namespace by default. Note: do not export
19 # names by default without a very good reason. Use EXPORT_OK instead.
20 # Do not simply export all your public functions/methods/constants.
21  
22 # This allows declaration use Rinchi::CIGI::AtmosphereControl ':all';
23 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
24 # will save memory.
25 2 our %EXPORT_TAGS = ( 'all' => [ qw(
26
27 ) ] );
28  
29 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
30  
31 2 our @EXPORT = qw(
32
33 );
34  
35 2 our $VERSION = '0.01';
36  
37 # Preloaded methods go here.
38  
39 =head1 NAME
40  
41 Rinchi::CIGIPP::CollisionDetectionVolumeNotification - Perl extension for the
42 Common Image Generator Interface - Collision Detection Volume Notification data packet.
43 data packet.
44 =head1 SYNOPSIS
45  
46 use Rinchi::CIGIPP::CollisionDetectionVolumeNotification;
47 my $cdv_ntc = Rinchi::CIGIPP::CollisionDetectionVolumeNotification->new();
48  
49 $packet_type = $cdv_ntc->packet_type();
50 $packet_size = $cdv_ntc->packet_size();
51 $entity_ident = $cdv_ntc->entity_ident(16373);
52 $volume_ident = $cdv_ntc->volume_ident(83);
53 $collision_type = $cdv_ntc->collision_type(Rinchi::CIGIPP->CollisionEntity);
54 $contacted_entity_ident = $cdv_ntc->contacted_entity_ident(36408);
55 $contacted_volume_ident = $cdv_ntc->contacted_volume_ident(60);
56  
57 =head1 DESCRIPTION
58  
59 The Collision Detection Volume Notification packet is used to notify the Host
60 when a collision occurs between two collision detection volumes. Volumes
61 belonging to the same entity are not tested against each other.
62  
63 The IG sends a Collision Detection Volume Notification packet for each volume
64 involved in a collision. For instance, if two volumes collide, two Collision
65 Detection Volume Notification packets will be sent. If a collision occurs that
66 involves three volumes, a total of six Collision Detection Volume Notification
67 packets will be sent.
68  
69 Unlike with collision detection segment testing, where the result is a single
70 point, the result of a collision detection volume test is the geometric
71 intersection of two volumes. This intersection is usually an irregular volume
72 with many vertices; therefore, the collision response data contains no spatial
73 information describing the intersection.
74  
75 Because collision detection volume testing does not involve polygon surfaces,
76 no material code is returned with the collision response data.
77  
78 Note that collision detection testing is performed every frame by the IG. If a
79 collision detection volume has been disabled, it will be excluded from all
80 collision testing.
81  
82 =head2 EXPORT
83  
84 None by default.
85  
86 #==============================================================================
87  
88 =item new $cdv_ntc = Rinchi::CIGIPP::CollisionDetectionVolumeNotification->new()
89  
90 Constructor for Rinchi::CollisionDetectionVolumeNotification.
91  
92 =cut
93  
94 2 ▶sub new {
Subroutine new: called CC=7 SCAR=29.8
Pod documented
95 2 my $class = shift;
96 2 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
97  
98 2 my $self = {
99 '_Buffer' => '',
100 '_ClassIdent' => 'f78b3dea-200e-11de-bdd4-001c25551abc',
101 '_Pack' => 'CCSCCSCCSI',
102 '_Swap1' => 'CCvCCvCCvV',
103 '_Swap2' => 'CCnCCnCCnN',
104 'packetType' => 114,
105 'packetSize' => 16,
106 'entityIdent' => 0,
107 'volumeIdent' => 0,
108 '_bitfields1' => 0, # Includes bitfields, and collisionType.
109 'collisionType' => 0,
110 'contactedEntityIdent' => 0,
111 'contactedVolumeIdent' => 0,
112 '_unused85' => 0,
113 '_unused86' => 0,
114 '_unused87' => 0,
115 };
116  
117 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
118 0 ▶ if (ref($_[0]) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 0 0 0
elsif (ref $_[0] eq 'HASH') { } 0 0 0
119 0 $self->{'_Buffer'} = $_[0][0];
120 } elsif (ref($_[0]) eq 'HASH') {
121 0 foreach my $attr (keys %{$_[0]}) {
122 0 ▶ $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /^_/ 0 0 0
123 }
124 }
125 }
126  
127 2 bless($self,$class);
128 2 return $self;
129 }
130  
131 #==============================================================================
132  
133 =item sub packet_type()
134  
135 $value = $cdv_ntc->packet_type();
136  
137 Data Packet Identifier.
138  
139 This attribute identifies this data packet as the Collision Detection Volume
140 Notification packet. The value of this attribute must be 114.
141  
142 =cut
143  
144 2 ▶sub packet_type() {
Subroutine packet_type: called CC=1 SCAR=0.0
Pod documented
145 2 my ($self) = @_;
146 2 return $self->{'packetType'};
147 }
148  
149 #==============================================================================
150  
151 =item sub packet_size()
152  
153 $value = $cdv_ntc->packet_size();
154  
155 Data Packet Size.
156  
157 This attribute indicates the number of bytes in this data packet. The value of
158 this attribute must be 16.
159  
160 =cut
161  
162 2 ▶sub packet_size() {
Subroutine packet_size: called CC=1 SCAR=0.0
Pod documented
163 2 my ($self) = @_;
164 2 return $self->{'packetSize'};
165 }
166  
167 #==============================================================================
168  
169 =item sub entity_ident([$newValue])
170  
171 $value = $cdv_ntc->entity_ident($newValue);
172  
173 Entity ID.
174  
175 This attribute indicates the entity to which the collision detection volume belongs.
176  
177 =cut
178  
179 2 ▶sub entity_ident() {
Subroutine entity_ident: called CC=2 SCAR=7.0
Pod documented
180 2 my ($self,$nv) = @_;
181 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
182 2 $self->{'entityIdent'} = $nv;
183 }
184 2 return $self->{'entityIdent'};
185 }
186  
187 #==============================================================================
188  
189 =item sub volume_ident([$newValue])
190  
191 $value = $cdv_ntc->volume_ident($newValue);
192  
193 Volume ID.
194  
195 This attribute indicates the ID of the collision detection volume within which
196 the collision occurred.
197  
198 This attribute, along with Entity ID, allows the Host to match this response
199 with the corresponding request.
200  
201 =cut
202  
203 2 ▶sub volume_ident() {
Subroutine volume_ident: called CC=2 SCAR=7.0
Pod documented
204 2 my ($self,$nv) = @_;
205 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
206 2 $self->{'volumeIdent'} = $nv;
207 }
208 2 return $self->{'volumeIdent'};
209 }
210  
211 #==============================================================================
212  
213 =item sub collision_type([$newValue])
214  
215 $value = $cdv_ntc->collision_type($newValue);
216  
217 Collision Type.
218  
219 This attribute indicates whether the collision occurred with another entity or
220 with a non-entity object such as the terrain.
221  
222 CollisionNonEntity 0
223 CollisionEntity 1
224  
225 =cut
226  
227 2 ▶sub collision_type() {
Subroutine collision_type: called CC=4 SCAR=15.5
Pod documented
228 2 my ($self,$nv) = @_;
229 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
230 2 ▶ if (($nv==0) or ($nv==1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv == 0 or $nv == 1) { } 2 0 2
Condition33%1/3
$nv == 0 or $nv == 1
l!l&&r!l&&!r
020
MC/DC0%0/2
$nv == 0 or $nv == 1
$nv == 0 $nv == 1
Truth table33%1/3
A or B
A= $nv == 0B= $nv == 1
ABresult
1X1
011
000
231 2 $self->{'collisionType'} = $nv;
232 2 $self->{'_bitfields1'} |= $nv &0x01;
233 } else {
234 0 carp "collision_type must be 0 (CollisionNonEntity), or 1 (CollisionEntity).";
235 }
236 }
237 2 return ($self->{'_bitfields1'} & 0x01);
238 }
239  
240 #==============================================================================
241  
242 =item sub contacted_entity_ident([$newValue])
243  
244 $value = $cdv_ntc->contacted_entity_ident($newValue);
245  
246 Contacted Entity ID.
247  
248 This attribute indicates the entity with which the collision occurred.
249  
250 If Collision Type is set to Non-entity (0), this attribute is ignored.
251  
252 =cut
253  
254 2 ▶sub contacted_entity_ident() {
Subroutine contacted_entity_ident: called CC=2 SCAR=7.0
Pod documented
255 2 my ($self,$nv) = @_;
256 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
257 2 $self->{'contactedEntityIdent'} = $nv;
258 }
259 2 return $self->{'contactedEntityIdent'};
260 }
261  
262 #==============================================================================
263  
264 =item sub contacted_volume_ident([$newValue])
265  
266 $value = $cdv_ntc->contacted_volume_ident($newValue);
267  
268 Contacted Volume ID.
269  
270 This attribute indicates the ID of the collision detection volume with which
271 the collision occurred.
272  
273 =cut
274  
275 2 ▶sub contacted_volume_ident() {
Subroutine contacted_volume_ident: called CC=2 SCAR=7.0
Pod documented
276 2 my ($self,$nv) = @_;
277 2 ▶ if (defined($nv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nv) 2 0 2
278 2 $self->{'contactedVolumeIdent'} = $nv;
279 }
280 2 return $self->{'contactedVolumeIdent'};
281 }
282  
283 #==========================================================================
284  
285 =item sub pack()
286  
287 $value = $cdv_ntc->pack();
288  
289 Returns the packed data packet.
290  
291 =cut
292  
293 2 ▶sub pack($) {
Subroutine pack: called CC=1 SCAR=0.0
Pod documented
294 2 my $self = shift ;
295
296 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
297 $self->{'packetType'},
298 $self->{'packetSize'},
299 $self->{'entityIdent'},
300 $self->{'volumeIdent'},
301 $self->{'_bitfields1'}, # Includes bitfields unused84, and collisionType.
302 $self->{'contactedEntityIdent'},
303 $self->{'contactedVolumeIdent'},
304 $self->{'_unused85'},
305 $self->{'_unused86'},
306 2 $self->{'_unused87'},
307 );
308  
309 2 return $self->{'_Buffer'};
310 }
311  
312 #==========================================================================
313  
314 =item sub unpack()
315  
316 $value = $cdv_ntc->unpack();
317  
318 Unpacks the packed data packet.
319  
320 =cut
321  
322 0 ▶sub unpack($) {
Subroutine unpack: not called CC=2 SCAR=17.9
Pod documented
323 0 my $self = shift @_;
324
325 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
326 0 $self->{'_Buffer'} = shift @_;
327 }
328 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
329 0 $self->{'packetType'} = $a;
330 0 $self->{'packetSize'} = $b;
331 0 $self->{'entityIdent'} = $c;
332 0 $self->{'volumeIdent'} = $d;
333 0 $self->{'_bitfields1'} = $e; # Includes bitfields unused84, and collisionType.
334 0 $self->{'contactedEntityIdent'} = $f;
335 0 $self->{'contactedVolumeIdent'} = $g;
336 0 $self->{'_unused85'} = $h;
337 0 $self->{'_unused86'} = $i;
338 0 $self->{'_unused87'} = $j;
339  
340 0 $self->{'collisionType'} = $self->collision_type();
341  
342 0 return $self->{'_Buffer'};
343 }
344  
345 #==========================================================================
346  
347 =item sub byte_swap()
348  
349 $obj_name->byte_swap();
350  
351 Byte swaps the packed data packet.
352  
353 =cut
354  
355 0 ▶sub byte_swap($) {
Subroutine byte_swap: not called CC=2 SCAR=17.9
Pod documented
356 0 my $self = shift @_;
357
358 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
359 0 $self->{'_Buffer'} = shift @_;
360 } else {
361 0 $self->pack();
362 }
363 0 my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
364  
365 0 $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g,$h,$i,$j);
366 0 $self->unpack();
367  
368 0 return $self->{'_Buffer'};
369 }
370  
371 2 1;
372 __END__
« CIGIPP/TerrestrialSurfaceConditionsControl.pm ↑ Summary CIGIPP/SensorResponse.pm »