Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -5,13 +5,11 @@
|
||||
#define tools_sg_atb_vertices
|
||||
|
||||
#include "vertices"
|
||||
#include "gstos"
|
||||
#include "../vmanip"
|
||||
|
||||
namespace tools {
|
||||
namespace sg {
|
||||
|
||||
class atb_vertices : public vertices, public gstos {
|
||||
class atb_vertices : public vertices {
|
||||
TOOLS_NODE(atb_vertices,tools::sg::atb_vertices,vertices)
|
||||
public:
|
||||
mf<float> rgbas;
|
||||
@@ -20,17 +18,15 @@ public:
|
||||
sf<float> epsilon;
|
||||
sf<bool> draw_edges;
|
||||
public:
|
||||
virtual const std::vector<field_desc>& node_fields() const {
|
||||
virtual const desc_fields& node_desc_fields() const {
|
||||
TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::atb_vertices)
|
||||
static std::vector<field_desc> s_v;
|
||||
if(s_v.empty()) {
|
||||
s_v = parent::node_fields();
|
||||
TOOLS_ADD_FIELD_DESC(rgbas)
|
||||
TOOLS_ADD_FIELD_DESC(nms)
|
||||
TOOLS_ADD_FIELD_DESC(do_back)
|
||||
TOOLS_ADD_FIELD_DESC(epsilon)
|
||||
TOOLS_ADD_FIELD_DESC(draw_edges)
|
||||
}
|
||||
static const desc_fields s_v(parent::node_desc_fields(),5, //WARNING : take care of count.
|
||||
TOOLS_ARG_FIELD_DESC(rgbas),
|
||||
TOOLS_ARG_FIELD_DESC(nms),
|
||||
TOOLS_ARG_FIELD_DESC(do_back),
|
||||
TOOLS_ARG_FIELD_DESC(epsilon),
|
||||
TOOLS_ARG_FIELD_DESC(draw_edges)
|
||||
);
|
||||
return s_v;
|
||||
}
|
||||
virtual void protocol_one_fields(std::vector<field*>& a_fields) const {
|
||||
@@ -47,7 +43,7 @@ private:
|
||||
add_field(&draw_edges);
|
||||
}
|
||||
protected: //gstos
|
||||
virtual unsigned int create_gsto(std::ostream&,sg::gl_manager& a_mgr) {
|
||||
virtual unsigned int create_gsto(std::ostream&,sg::render_manager& a_mgr) {
|
||||
//unsigned int npt = xyzs.values().size()/3;
|
||||
//::printf("debug : atb_vertices : %lu : create_gsto : %u\n",this,npt);
|
||||
|
||||
@@ -127,6 +123,13 @@ public:
|
||||
if(touched()) {
|
||||
if(do_back.value()) gen_back();
|
||||
if(draw_edges.value()) gen_edges();
|
||||
#ifdef __APPLE__
|
||||
m_all_a_one = true;
|
||||
{tools_vforcit_npp(float,rgbas.values(),it) {
|
||||
if(*(it+3)!=1) {m_all_a_one = false;break;}
|
||||
it += 4;
|
||||
}}
|
||||
#endif //__APPLE__
|
||||
reset_touched();
|
||||
}
|
||||
if(xyzs.empty()) return;
|
||||
@@ -134,10 +137,13 @@ public:
|
||||
const state& state = a_action.state();
|
||||
|
||||
if(state.m_use_gsto) {
|
||||
unsigned int _id = get_gsto_id(a_action.out(),a_action.gl_manager());
|
||||
unsigned int _id = get_gsto_id(a_action.out(),a_action.render_manager());
|
||||
if(_id) {
|
||||
a_action.begin_gsto(_id);
|
||||
if(rgbas.size()) {
|
||||
#ifdef __APPLE__
|
||||
bool restore_blend = check_set_blend(a_action);
|
||||
#endif
|
||||
if(nms.size()) {
|
||||
size_t npt = xyzs.values().size()/3;
|
||||
bufpos pos_xyzs = 0;
|
||||
@@ -181,7 +187,7 @@ public:
|
||||
}
|
||||
if(do_back.value()) a_action.draw_gsto_vcn(mode.value(),npt,pos_back_xyzs,pos_rgbas,pos_back_nms);
|
||||
a_action.draw_gsto_vcn(mode.value(),npt,pos_xyzs,pos_rgbas,pos_nms);
|
||||
a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
|
||||
if(draw_edges.value()) a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
|
||||
} else {
|
||||
if(do_back.value()) a_action.draw_gsto_vcn(mode.value(),npt,pos_back_xyzs,pos_rgbas,pos_back_nms);
|
||||
a_action.draw_gsto_vcn(mode.value(),npt,pos_xyzs,pos_rgbas,pos_nms);
|
||||
@@ -200,6 +206,9 @@ public:
|
||||
a_action.draw_gsto_vc(mode.value(),npt,pos_xyzs,pos_rgbas);
|
||||
}
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
if(restore_blend) a_action.set_blend(true);
|
||||
#endif
|
||||
} else { //rgbas.empty()
|
||||
if(nms.size()) {
|
||||
size_t npt = xyzs.values().size()/3;
|
||||
@@ -234,11 +243,16 @@ public:
|
||||
}
|
||||
|
||||
} else {
|
||||
clean_gstos(&a_action.gl_manager());
|
||||
clean_gstos(&a_action.render_manager());
|
||||
}
|
||||
|
||||
// immediate rendering :
|
||||
if(rgbas.size()) {
|
||||
|
||||
#ifdef __APPLE__
|
||||
bool restore_blend = check_set_blend(a_action);
|
||||
#endif
|
||||
|
||||
if(nms.size()) {
|
||||
if(gl::is_line(mode.value())) {
|
||||
//Same logic as Inventor SoLightModel.model = BASE_COLOR.
|
||||
@@ -258,13 +272,12 @@ public:
|
||||
}
|
||||
if(do_back.value()) a_action.draw_vertex_color_normal_array(mode.value(),m_back_xyzs,rgbas.values(),m_back_nms);
|
||||
a_action.draw_vertex_color_normal_array(mode.value(),xyzs.values(),rgbas.values(),nms.values());
|
||||
a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
|
||||
if(draw_edges.value()) a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
|
||||
} else {
|
||||
if(do_back.value()) a_action.draw_vertex_color_normal_array(mode.value(),m_back_xyzs,rgbas.values(),m_back_nms);
|
||||
a_action.draw_vertex_color_normal_array(mode.value(),xyzs.values(),rgbas.values(),nms.values());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if(gl::is_line(mode.value())) {
|
||||
//Same logic as Inventor SoLightModel.model = BASE_COLOR.
|
||||
@@ -276,6 +289,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
if(restore_blend) a_action.set_blend(true);
|
||||
#endif
|
||||
} else { //rgbas.empty()
|
||||
if(nms.size()) {
|
||||
if(gl::is_line(mode.value())) {
|
||||
@@ -309,6 +325,9 @@ public:
|
||||
,m_xyzs_pos(0)
|
||||
,m_rgbas_pos(0)
|
||||
,m_nms_pos(0)
|
||||
#ifdef __APPLE__
|
||||
,m_all_a_one(true)
|
||||
#endif
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
@@ -323,7 +342,6 @@ public:
|
||||
public:
|
||||
atb_vertices(const atb_vertices& a_from)
|
||||
:parent(a_from)
|
||||
,gstos(a_from)
|
||||
,rgbas(a_from.rgbas)
|
||||
,nms(a_from.nms)
|
||||
,do_back(a_from.do_back)
|
||||
@@ -332,6 +350,9 @@ public:
|
||||
,m_xyzs_pos(a_from.m_xyzs_pos)
|
||||
,m_rgbas_pos(a_from.m_rgbas_pos)
|
||||
,m_nms_pos(a_from.m_nms_pos)
|
||||
#ifdef __APPLE__
|
||||
,m_all_a_one(true)
|
||||
#endif
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
@@ -340,7 +361,6 @@ public:
|
||||
}
|
||||
atb_vertices& operator=(const atb_vertices& a_from){
|
||||
parent::operator=(a_from);
|
||||
gstos::operator=(a_from);
|
||||
rgbas = a_from.rgbas;
|
||||
nms = a_from.nms;
|
||||
do_back = a_from.do_back;
|
||||
@@ -362,6 +382,17 @@ public:
|
||||
rgbas.add(a_a);
|
||||
}
|
||||
|
||||
template <class COLOR>
|
||||
void add_pos_color(float a_x,float a_y,float a_z,const COLOR& a_col) {
|
||||
xyzs.add(a_x);
|
||||
xyzs.add(a_y);
|
||||
xyzs.add(a_z);
|
||||
rgbas.add(a_col.r());
|
||||
rgbas.add(a_col.g());
|
||||
rgbas.add(a_col.b());
|
||||
rgbas.add(a_col.a());
|
||||
}
|
||||
|
||||
template <class VEC,class COLOR>
|
||||
void add_pos_color(const VEC& a_pos,const COLOR& a_col) {
|
||||
xyzs.add(a_pos.x());
|
||||
@@ -511,7 +542,7 @@ protected:
|
||||
m_back_xyzs.clear();
|
||||
m_back_nms.clear();
|
||||
|
||||
clean_gstos(); //must reset for all gl_manager.
|
||||
clean_gstos(); //must reset for all render_manager.
|
||||
|
||||
std::vector<float>& _xyzs = xyzs.values();
|
||||
std::vector<float>& _nms = nms.values();
|
||||
@@ -579,7 +610,7 @@ protected:
|
||||
void gen_edges(){
|
||||
m_edges.clear();
|
||||
|
||||
clean_gstos(); //must reset for all gl_manager.
|
||||
clean_gstos(); //must reset for all render_manager.
|
||||
|
||||
std::vector<float>& _xyzs = xyzs.values();
|
||||
if(_xyzs.empty()) return;
|
||||
@@ -622,6 +653,32 @@ protected:
|
||||
pxyz += 9;
|
||||
}
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
protected:
|
||||
// macOS/Mojave : on this version, points are blended even if alpha is one !
|
||||
bool check_set_blend(render_action& a_action) {
|
||||
bool restore_blend = false;
|
||||
const state& state = a_action.state();
|
||||
if(state.m_GL_BLEND) {
|
||||
/*
|
||||
bool all_a_one = true;
|
||||
tools_vforcit_npp(float,rgbas.values(),it) {
|
||||
if(*(it+3)!=1) {all_a_one = false;break;}
|
||||
it += 4;
|
||||
}
|
||||
if(all_a_one) {
|
||||
a_action.set_blend(false);
|
||||
restore_blend = true;
|
||||
}
|
||||
*/
|
||||
if(m_all_a_one) {
|
||||
a_action.set_blend(false);
|
||||
restore_blend = true;
|
||||
}
|
||||
}
|
||||
return restore_blend;
|
||||
}
|
||||
#endif
|
||||
protected:
|
||||
std::vector<float> m_back_xyzs;
|
||||
std::vector<float> m_back_nms;
|
||||
@@ -630,6 +687,9 @@ protected:
|
||||
size_t m_xyzs_pos;
|
||||
size_t m_rgbas_pos;
|
||||
size_t m_nms_pos;
|
||||
#ifdef __APPLE__
|
||||
bool m_all_a_one;
|
||||
#endif
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user