| 708 | } |
| 709 | |
| 710 | void afxConstraintMgr::create_constraint(const afxConstraintDef& def) |
| 711 | { |
| 712 | if (def.mDef_type == afxConstraintDef::CONS_UNDEFINED) |
| 713 | return; |
| 714 | |
| 715 | //Con::printf("CON - %s [%s] [%s] h=%g", def.cons_type_name, def.cons_src_name, def.cons_node_name, def.history_time); |
| 716 | |
| 717 | bool want_history = (def.mHistory_time > 0.0f); |
| 718 | |
| 719 | // constraint is an arbitrary named scene object |
| 720 | // |
| 721 | if (def.mDef_type == afxConstraintDef::CONS_SCENE) |
| 722 | { |
| 723 | if (def.mCons_src_name == ST_NULLSTRING) |
| 724 | return; |
| 725 | |
| 726 | // find the arbitrary object by name |
| 727 | SceneObject* arb_obj; |
| 728 | if (mOn_server) |
| 729 | { |
| 730 | arb_obj = dynamic_cast<SceneObject*>(Sim::findObject(def.mCons_src_name)); |
| 731 | if (!arb_obj) |
| 732 | Con::errorf("afxConstraintMgr -- failed to find scene constraint source, \"%s\" on server.", |
| 733 | def.mCons_src_name); |
| 734 | } |
| 735 | else |
| 736 | { |
| 737 | arb_obj = find_object_from_name(def.mCons_src_name); |
| 738 | if (!arb_obj) |
| 739 | Con::errorf("afxConstraintMgr -- failed to find scene constraint source, \"%s\" on client.", |
| 740 | def.mCons_src_name); |
| 741 | } |
| 742 | |
| 743 | // if it's a shapeBase object, create a Shape or ShapeNode constraint |
| 744 | if (dynamic_cast<ShapeBase*>(arb_obj)) |
| 745 | { |
| 746 | if (def.mCons_node_name == ST_NULLSTRING && !def.mPos_at_box_center) |
| 747 | { |
| 748 | afxShapeConstraint* cons = newShapeCons(this, def.mCons_src_name, want_history); |
| 749 | cons->mCons_def = def; |
| 750 | cons->set((ShapeBase*)arb_obj); |
| 751 | afxConstraintList* list = new afxConstraintList(); |
| 752 | list->push_back(cons); |
| 753 | mConstraints_v.push_back(list); |
| 754 | } |
| 755 | else if (def.mPos_at_box_center) |
| 756 | { |
| 757 | afxShapeConstraint* cons = newShapeCons(this, def.mCons_src_name, want_history); |
| 758 | cons->mCons_def = def; |
| 759 | cons->set((ShapeBase*)arb_obj); |
| 760 | afxConstraintList* list = mConstraints_v[mConstraints_v.size()-1]; // SHAPE-NODE CONS-LIST (#scene)(#center) |
| 761 | if (list && (*list)[0]) |
| 762 | list->push_back(cons); |
| 763 | } |
| 764 | else |
| 765 | { |
| 766 | afxShapeNodeConstraint* sub = newShapeNodeCons(this, def.mCons_src_name, def.mCons_node_name, want_history); |
| 767 | sub->mCons_def = def; |
nothing calls this directly
no test coverage detected