Add Collision Info
This commit is contained in:
@@ -427,6 +427,150 @@ function _decodeDetectionHistory(bb: ByteBuffer): DetectionHistory {
|
||||
return message;
|
||||
}
|
||||
|
||||
export interface CollisionInfo {
|
||||
source?: number;
|
||||
ball_identifiers?: { [key: number]: Point };
|
||||
wall_identifier?: number;
|
||||
frame_index?: number;
|
||||
static?: boolean;
|
||||
}
|
||||
|
||||
export function encodeCollisionInfo(message: CollisionInfo): Uint8Array {
|
||||
let bb = popByteBuffer();
|
||||
_encodeCollisionInfo(message, bb);
|
||||
return toUint8Array(bb);
|
||||
}
|
||||
|
||||
function _encodeCollisionInfo(message: CollisionInfo, bb: ByteBuffer): void {
|
||||
// optional uint32 source = 1;
|
||||
let $source = message.source;
|
||||
if ($source !== undefined) {
|
||||
writeVarint32(bb, 8);
|
||||
writeVarint32(bb, $source);
|
||||
}
|
||||
|
||||
// optional map<uint32, Point> ball_identifiers = 2;
|
||||
let map$ball_identifiers = message.ball_identifiers;
|
||||
if (map$ball_identifiers !== undefined) {
|
||||
for (let key in map$ball_identifiers) {
|
||||
let nested = popByteBuffer();
|
||||
let value = map$ball_identifiers[key];
|
||||
writeVarint32(nested, 8);
|
||||
writeVarint32(nested, +key);
|
||||
writeVarint32(nested, 18);
|
||||
let nestedValue = popByteBuffer();
|
||||
_encodePoint(value, nestedValue);
|
||||
writeVarint32(nested, nestedValue.limit);
|
||||
writeByteBuffer(nested, nestedValue);
|
||||
pushByteBuffer(nestedValue);
|
||||
writeVarint32(bb, 18);
|
||||
writeVarint32(bb, nested.offset);
|
||||
writeByteBuffer(bb, nested);
|
||||
pushByteBuffer(nested);
|
||||
}
|
||||
}
|
||||
|
||||
// optional uint32 wall_identifier = 3;
|
||||
let $wall_identifier = message.wall_identifier;
|
||||
if ($wall_identifier !== undefined) {
|
||||
writeVarint32(bb, 24);
|
||||
writeVarint32(bb, $wall_identifier);
|
||||
}
|
||||
|
||||
// optional uint32 frame_index = 4;
|
||||
let $frame_index = message.frame_index;
|
||||
if ($frame_index !== undefined) {
|
||||
writeVarint32(bb, 32);
|
||||
writeVarint32(bb, $frame_index);
|
||||
}
|
||||
|
||||
// optional bool static = 5;
|
||||
let $static = message.static;
|
||||
if ($static !== undefined) {
|
||||
writeVarint32(bb, 40);
|
||||
writeByte(bb, $static ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
export function decodeCollisionInfo(binary: Uint8Array): CollisionInfo {
|
||||
return _decodeCollisionInfo(wrapByteBuffer(binary));
|
||||
}
|
||||
|
||||
function _decodeCollisionInfo(bb: ByteBuffer): CollisionInfo {
|
||||
let message: CollisionInfo = {} as any;
|
||||
|
||||
end_of_message: while (!isAtEnd(bb)) {
|
||||
let tag = readVarint32(bb);
|
||||
|
||||
switch (tag >>> 3) {
|
||||
case 0:
|
||||
break end_of_message;
|
||||
|
||||
// optional uint32 source = 1;
|
||||
case 1: {
|
||||
message.source = readVarint32(bb) >>> 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional map<uint32, Point> ball_identifiers = 2;
|
||||
case 2: {
|
||||
let values =
|
||||
message.ball_identifiers || (message.ball_identifiers = {});
|
||||
let outerLimit = pushTemporaryLength(bb);
|
||||
let key: number | undefined;
|
||||
let value: Point | undefined;
|
||||
end_of_entry: while (!isAtEnd(bb)) {
|
||||
let tag = readVarint32(bb);
|
||||
switch (tag >>> 3) {
|
||||
case 0:
|
||||
break end_of_entry;
|
||||
case 1: {
|
||||
key = readVarint32(bb) >>> 0;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
let valueLimit = pushTemporaryLength(bb);
|
||||
value = _decodePoint(bb);
|
||||
bb.limit = valueLimit;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
skipUnknownField(bb, tag & 7);
|
||||
}
|
||||
}
|
||||
if (key === undefined || value === undefined)
|
||||
throw new Error("Invalid data for map: ball_identifiers");
|
||||
values[key] = value;
|
||||
bb.limit = outerLimit;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional uint32 wall_identifier = 3;
|
||||
case 3: {
|
||||
message.wall_identifier = readVarint32(bb) >>> 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional uint32 frame_index = 4;
|
||||
case 4: {
|
||||
message.frame_index = readVarint32(bb) >>> 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional bool static = 5;
|
||||
case 5: {
|
||||
message.static = !!readByte(bb);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
skipUnknownField(bb, tag & 7);
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
export interface Path {
|
||||
start_frame?: number;
|
||||
end_frame?: number;
|
||||
@@ -434,6 +578,8 @@ export interface Path {
|
||||
rle_detections?: RLEDetectionHistory;
|
||||
not_present?: boolean;
|
||||
is_static?: boolean;
|
||||
start_info?: CollisionInfo;
|
||||
end_info?: CollisionInfo;
|
||||
}
|
||||
|
||||
export function encodePath(message: Path): Uint8Array {
|
||||
@@ -492,6 +638,28 @@ function _encodePath(message: Path, bb: ByteBuffer): void {
|
||||
writeVarint32(bb, 48);
|
||||
writeByte(bb, $is_static ? 1 : 0);
|
||||
}
|
||||
|
||||
// optional CollisionInfo start_info = 7;
|
||||
let $start_info = message.start_info;
|
||||
if ($start_info !== undefined) {
|
||||
writeVarint32(bb, 58);
|
||||
let nested = popByteBuffer();
|
||||
_encodeCollisionInfo($start_info, nested);
|
||||
writeVarint32(bb, nested.limit);
|
||||
writeByteBuffer(bb, nested);
|
||||
pushByteBuffer(nested);
|
||||
}
|
||||
|
||||
// optional CollisionInfo end_info = 8;
|
||||
let $end_info = message.end_info;
|
||||
if ($end_info !== undefined) {
|
||||
writeVarint32(bb, 66);
|
||||
let nested = popByteBuffer();
|
||||
_encodeCollisionInfo($end_info, nested);
|
||||
writeVarint32(bb, nested.limit);
|
||||
writeByteBuffer(bb, nested);
|
||||
pushByteBuffer(nested);
|
||||
}
|
||||
}
|
||||
|
||||
export function decodePath(binary: Uint8Array): Path {
|
||||
@@ -548,6 +716,22 @@ function _decodePath(bb: ByteBuffer): Path {
|
||||
break;
|
||||
}
|
||||
|
||||
// optional CollisionInfo start_info = 7;
|
||||
case 7: {
|
||||
let limit = pushTemporaryLength(bb);
|
||||
message.start_info = _decodeCollisionInfo(bb);
|
||||
bb.limit = limit;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional CollisionInfo end_info = 8;
|
||||
case 8: {
|
||||
let limit = pushTemporaryLength(bb);
|
||||
message.end_info = _decodeCollisionInfo(bb);
|
||||
bb.limit = limit;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
skipUnknownField(bb, tag & 7);
|
||||
}
|
||||
|
Reference in New Issue
Block a user