vpaint icon indicating copy to clipboard operation
vpaint copied to clipboard

Color of key vertices not preserved when opening

Open dalboris opened this issue 6 years ago • 0 comments

Currently, when opening a file, all key vertices are made black (= rgba(0, 0, 0, 1) ), regardless of their color attribute.

For example, the examples/vpaint-1.6/torus.vec file has key vertices with the color rgba(0, 0, 255, 1) (which makes no sense and was probably another bug... but anyway), and when opening and saving this file, the color becomes rgba(0, 0, 0, 1). The expected behavior would be to preserve the original color.

I've tracked down the issue, here is what happens:

  1. VAC::read(xml) calls new KeyVertex(this, xml);
  2. which first calls the base constructor Cell(vac, xml)
  3. which correctly sets color_ from the value in the file
  4. but then the derived constructor KeyVertex(vac, xml) is called
  5. which calls KeyVertex::initColor()
void KeyVertex::initColor()
{
    color_[0] = 0;
    color_[1] = 0;
    color_[2] = 0;
    color_[3] = 1;
}

I suspect that I did this on purpose do handle incorrect values in the example files, but what I should do is fix the examples and preserve vertices color when reading a file (even though this color is never used currently, since vertices are only visible in topology mode or when highlighted/selected, in which situations they are displayed in another color anyway).

dalboris avatar Nov 04 '18 10:11 dalboris