Jump to content

Cant append vector in map


photo

Recommended Posts

Hi All
       
I'm rtying to add vector in map like this:

int Events[] ; 
Events.append(ivec3(1,1,1));
Events.append(ivec3(2,2,2)); // this vector was added 
Events.append(ivec3(2,3,4)); // this vector was not added 
log.message(" size = %i  \n", Events.size());

message:
 size = 2

What am i doing wrong? i want to add all three vectors.
Link to comment

Hi Alexander,

 

If you want to fill map with key and value you can try to use append(key, value) method:

Events.append(1, ivec3(1,1,1));
Events.append(2, ivec3(2,2,2)); 
Events.append(3, ivec3(2,3,4));

We will also investigate further your use-case. Probably, there is some incorrect behavior appears.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi Alexander,

 

A small update. We are deeply sorry, but mentioned before fix will not be included in the next SDK update.

 

Unigine Map container internally uses binary tree to add elements into it, so the comparison operator is required for all kind of objects that should be added into this Map. Unfortunately, there is no correct way to compare vectors, so you can override "<" method for vector in UnigineScript code and write some custom vector compare logic:

class OurMapCompontent {
    int x;
    int y;
    int z;

    OurMapCompontent(ivec3 vector) {
        x = vector.x;
        y = vector.y;
        z = vector.z;
    }

    int operator<(OurMapCompontent other) {

        // Your comprasion code for vector
        // ...
    }
};

Sorry for the incovenience caused.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...